|
发表于 2011-11-21 20:36
|
显示全部楼层
本楼为最佳答案
- Option Explicit
- Sub GetIP()
- Dim OpSysSet As Object, OpSys As Object, IP, GIP$, ComputerName
- 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
- GIP = IP
- Next
- End If
- Next
- MsgBox "本机IP: " & GIP
- End Sub
复制代码 |
|