0

我试图通过 Visual FoxPro 9 从我的 ActiveX 组件中获取动态数组,但没有运气。(编辑和工作示例)

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

有人可以解释一下这段代码有什么问题吗?

4

1 回答 1

1

我不知道您的“nnetcom.oMain”ActiveX 控件是什么,但您可以通过 VFP 直接获取

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

For Each 循环循环通过 [Win32_NetworkAdapter] 类结构的类实例。您可以从该列表中获得几乎任何您想要的东西。 1

于 2012-04-23T19:09:24.240 回答