|
本帖最后由 tsmirs 于 2010-10-11 23:16 编辑
Func _NetworkAdapterInfo()
Local $colItems = ""
Local $objWMIService
Local $NetworkAdapterID = 0
Local $NetworkAdapterName = ""
Local $NetworkAdapterGateway = ""
Local $NetworkAdapterHostName = ""
Local $NetworkAdapterIPaddress = ""
Local $NetworkAdapterDNS1 = ""
Local $NetworkAdapterDNS2 = ""
Local $NetworkAdapterSubnet = ""
Local $NetworkAdapterMAC = ""
Local $NetworkAdapterNetConnectionID = ""
Local $NetworkAdapterInfo[10][10] ;最高10块网卡.
$NetworkAdapterInfo[0][0] = 0
$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", 0x10 + 0x20)
$colItem2 = $objWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus >0', "WQL", 0x10 + 0x20)
If IsObj($colItems) Then
For $objItem In $colItems
$NetworkAdapterName = $objItem.Description
$NetworkAdapterGateway = $objItem.DefaultIPGateway(0)
$NetworkAdapterHostName = $objItem.DNSHostName
$NetworkAdapterIPaddress = $objItem.IPAddress(0)
$NetworkAdapterDNS1 = $objItem.DNSServerSearchOrder(0)
$NetworkAdapterDNS2 = $objItem.DNSServerSearchOrder(1)
$NetworkAdapterSubnet = $objItem.IPSubnet(0)
$NetworkAdapterMAC = $objItem.MACAddress
$NetworkAdapterID += 1
$NetworkAdapterInfo[0][0] = $NetworkAdapterID
$NetworkAdapterInfo[$NetworkAdapterID][0] = $NetworkAdapterID
$NetworkAdapterInfo[$NetworkAdapterID][1] = $NetworkAdapterName
$NetworkAdapterInfo[$NetworkAdapterID][2] = $NetworkAdapterGateway
$NetworkAdapterInfo[$NetworkAdapterID][3] = $NetworkAdapterHostName
$NetworkAdapterInfo[$NetworkAdapterID][4] = $NetworkAdapterIPaddress
$NetworkAdapterInfo[$NetworkAdapterID][5] = $NetworkAdapterDNS1
$NetworkAdapterInfo[$NetworkAdapterID][6] = $NetworkAdapterDNS2
$NetworkAdapterInfo[$NetworkAdapterID][7] = $NetworkAdapterSubnet
$NetworkAdapterInfo[$NetworkAdapterID][8] = $NetworkAdapterMAC
Next
Else
Return $NetworkAdapterInfo
EndIf
If IsObj($colItem2) Then
$NetworkAdapterID = 0
For $objItem2s In $colItem2
$NetworkAdapterNetConnectionID = $objItem2s.NetConnectionID
$NetworkAdapterID += 1
$NetworkAdapterInfo[$NetworkAdapterID][9] = $NetworkAdapterNetConnectionID
Next
Return $NetworkAdapterInfo
Else
Return $NetworkAdapterInfo
EndIf
EndFunc ;==>_NetworkAdapterInfo
$info = _NetworkAdapterInfo()
MsgBox(4096, "测试",$info[1][1], 10)
这个脚本在WIN2000运行正常,WINXP运行后出现:ERROR:变量类型必须为对象类型("object") 怎么处理!!
请高手帮帮忙!! |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|