- 帖子
- 323
- 主題
- 6
- 精華
- 0
- 積分
- 313
- 點名
- 0
- 作業系統
- xp
- 軟體版本
- 2k
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2015-6-24
- 最後登錄
- 2025-5-3
|
2#
發表於 2016-2-28 23:24
| 只看該作者
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 |
|