本帖最后由 pcl_test 于 2017-6-15 19:23 编辑
| | | If Ping("www.ip138.com") Then | | Msgbox "你的外网IP是:" & HttpGet("http://1212.ip138.com/ic.asp") | | Else | | Msgbox "你的电脑没有连通外网。" | | End If | | | | Function HttpGet(ByVal url) | | On Error Resume Next | | With CreateObject("Msxml2.ServerXMLHTTP") | | .open "GET", url, False | | .send | | HttpGet = split(split(.responseText, "[")(1), "]")(0) | | End With | | End Function | | | | Function Ping(ByVal host) | | On Error Resume Next | | Ping = False | | Dim objWMIService, colItems | | Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") | | Set colItems = objWMIService.ExecQuery("Select * From Win32_PingStatus Where Address='" & host & "'") | | For Each objItem In colItems | | If objItem.StatusCode = 0 Then Ping = True : Exit For | | Next | | End FunctionCOPY |
|