- 帖子
- 549
- 主題
- 152
- 精華
- 0
- 積分
- 691
- 點名
- 0
- 作業系統
- WIN7
- 軟體版本
- OFFICE 2010
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2013-8-10
- 最後登錄
- 2022-9-7
 
|
[發問] 為何VBA查詢的IP與實際網頁上查詢的IP不同?
不好意思麻煩各位大大,
小弟已經找到大約十個可以查詢到IP的VBA程式碼(當然有許多重複的)
但查詢結果都是192.168.xx.xx
可是小弟要的是下方網站
http://dir.twseo.org/ip-check.php
所查詢出來的IP=42.72.5.xxx
為何所有VBA程式碼查詢出來的都跟網頁查詢的IP不同?例如下方程式碼- 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
- strIPAddress = strIPAddress & Join(IPAddress, ", ")
- End If
- Next
- MsgBox strIPAddress
- End Function
複製代碼 各位大大可自行測試看看這兩種方式
會查詢出兩種不同的IP
要如何才能夠查詢到網頁的那種IP位置呢? |
|