-- 作者:baoxyang
-- 发布时间:2012/7/16 16:34:00
--
哦,是获取外网有问题。
Dim WinHttpReq As Object = CreateObject("Msxml2.ServerXMLHTTP") WinHttpReq.Open("GET", "http://www.ip138.com/ip2city.asp") WinHttpReq.Send \'正则表达式解析出外网IP Dim MyRegExp MyRegExp = CreateObject("VBScript.RegExp") MyRegExp.Pattern = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)" MyRegExp.IgnoreCase = True MyRegExp.Global = True Dim Matches As object = MyRegExp.Execute(WinHttpReq.ResponseText) Vars("外网IP") = Matches.Item(0).Value Dim HostName As String Dim IPAdress As System.Net.IPAddress HostName = System.Net.Dns.GetHostName \'获得本机的机器名 IPAdress = System.Net.Dns.GetHostByName(HostName).AddressList.GetValue(0) \'获得本机的IP \'\'OutPut.Show( HostName ) \'本机机器名 Vars("内网IP") = IPAdress.ToString \'本机的IP OutPut.Show(IPAdress.ToString)
|