Sub GetObject获取IP地址()
ComputerName = "localhost"
Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate}//" & ComputerName).ExecQuery("SELECT index, IPAddress FROM Win32_NetworkAdapterConfiguration")
For Each OpSys In OpSysSet
If TypeName(OpSys.IPAddress) <> "Null" Then
For Each ip In OpSys.IPAddress
MsgBox ip, 64, "IP地址"
Next
End If
Next
End Sub