- ©«¤l
- 319
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 309
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- 2k
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2015-6-24
- ³Ì«áµn¿ý
- 2024-4-27
|
Function GetIPAddress()
Const strComputer As String = "." ' Computer name. Dot means local computer
Dim objWMIService, IPConfigSet, IPConfig, IPAddress, i
Dim strIPAddress As String
' Connect to the WMI service
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Get all TCP/IP-enabled network adapters
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
' Get all IP addresses associated with these adapters
For Each IPConfig In IPConfigSet
IPAddress = IPConfig.IPAddress
If Not IsNull(IPAddress) Then
If InStr(1, IPConfig.Description, "WAN (", vbTextCompare) Then
MsgBox "ºô¶ IP = " + IPAddress(0)
End If
strIPAddress = strIPAddress & Join(IPAddress, "/") + vbCrLf
End If
Next
MsgBox strIPAddress
End Function |
|