0

I'm trying to get Dynamic Arrays from my ActiveX component trough Visual FoxPro 9, but with no luck. (Edited and Working example)

LOCAL objMain, objAdapt

#define CrLf CHR(13) + CHR(10)

stMsg = ""

objMain = CREATEOBJECT('nnetsdk.oMain')

objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")

objAdapt = CREATEOBJECT('nnetsdk.oNetworkAdapter')

objAdapt.GetNetworkAdapters && Collects Network Adapter information

vrAdapters = objAdapt.cName && cName holds collected Network Adapter names

FOR EACH vrAdapter IN vrAdapters
 stMsg = stMsg + vrAdapter + CrLf
ENDFOR

MESSAGEBOX(stMsg,64,"List Network Adapters")

RELEASE objAdapt
RELEASE objMain

Can someone explain me what is wrong with this code?

Rob Hruska
  • 118,520
  • 32
  • 167
  • 192
beic
  • 127
  • 1
  • 2
  • 16

1 Answers1

1

I don't know what your "nnetcom.oMain" ActiveX control is, but you can get directly from VFP via

lcComputerName = "."
loWMIService = GETOBJECT("winmgmts:\\" + lcComputerName + "\root\cimv2")
loItems = loWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)

FOR EACH loItem IN loItems
    lcMACAddress = loItem.MACAddress
    IF !ISNULL(lcMACAddress)
        */ then, you can look at the object properties, such as 
        lcDescription = loItem.Description
        lcMacAddress = loItem.MACAddress
        lcNetConnectionID = NVL( loItem.NetConnectionID, "" )
   ENDIF
ENDFOR

the For Each loop cycles through class instances of the [Win32_NetworkAdapter] class structure. You can get almost anything you want from that list. 1

DRapp
  • 47,638
  • 12
  • 72
  • 142
  • Hi DRapp, Yes, I know the WMI, in fact my ActiveX component uses it. The **objAdapt.cName** holds the collected network adapter names in Array. – beic Apr 23 '12 at 19:27
  • @beic, then I guess I'd be curious why using an ActiveX control when VFP can get it and process an array directly too. – DRapp Apr 23 '12 at 19:51
  • Yes, but I developing a sort of Framework component...anyway, you helped me a lot with that line of code **FOR EACH loItem IN loItems**, now its working perfectly...I upvoted you proposition and accepted as an Answer! Thanks... ;-) p.s. I will add the corrected example to my post! – beic Apr 23 '12 at 20:02