- Function GetIP
- Dim wmi
- Set wmi=GetObject("winmgmts:\\.\root\cimv2")
- Set wmq=wmi.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled='True'")
- For Each obj in wmq
- msgbox obj.ipaddress(0) & vbCrLf & obj.defaultipgateway(0) & vbCrLf & obj.IPSubnet(0)
- msgbox Ubound(obj.IPAddress)
- For i= 0 to Ubound(obj.IPAddress)
- Msgbox obj.IPAddress(i) & obj.IPSubnet(i) & i
- Next
- Next
- End Function
复制代码
- Function GetIP
- Dim wmi
- Set wmi=GetObject("winmgmts:\\.\root\cimv2")
- Set wmq=wmi.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled='true'")
- For Each obj in wmq
- msgbox obj.ipaddress(0)
- msgbox obj.ipaddress(1)
- msgbox obj.ipaddress
- Next
- End Function
复制代码
例一中obj.ipaddress的上限也为0,但被识别为一个数组,是否IP地址这样的类型是一个特殊的类型 |