本帖最后由 pcl_test 于 2016-7-5 13:47 编辑
- Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
- Set Items = wmiService.ExecQuery("Select * From Win32_NetworkAdapter")
- s=""
- For Each objItem in Items
- If LCase(Left(objItem.PNPDeviceID, 4))="pci\" Then
- Set Its = wmiService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration where Caption='"& objItem.Caption &"'")
- For Each It in Its
- If not IsNull(It.MACAddress) Then
- n=n+1
- s=s&"网卡"& n &":"&vbCrLf _
- &"网卡名称:"& It.Caption &vbCrLf _
- &"物理地址:"& It.MACAddress &vbCrLf&vbCrLf
- If not IsNull(It.IPAddress) Then
- s=left(s,len(s)-2)&"IPv4地址:"& It.IPAddress(0) _
- & vbCrLf &"IPv6地址:"& It.IPAddress(1) &vbCrLf&vbCrLf
- End If
- End If
- Next
- End If
- Next
- msgbox s
复制代码
|