vfp9想得到外网的IP值与内网IP值,请高手们帮忙!
我想得到外网的IP值(公网那种)
还有想得到内网IP值如192.168.0.100....,请高手们帮忙!
[解决办法]
内网IP:
方法一:
ox=Createobject("MSwinsock.Winsock")
?'IP地址:',ox.LocalIP
Local oWMI As Object,oLocal As Object,oHARDWARE As Object,object1 As Object
oWMI=Createobject("WbemScripting.SWbemLocator")
oLocal=oWMI.ConnectServer(".", "root\cimv2")
oHARDWARE=oLocal.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=1")
For Each object1 In oHARDWARE
LcIP=object1.Properties_('IPAddress').Value
Exit
Endfor
?'IP地址:',LcIP
Clear
oHttp=Newobject('Microsoft.XmlHttp')
oHttp.Open('GET','http://iframe.ip138.com/ic.asp?ts='+Sys(2015))
oHttp.Send()
Do While oHttp.readyState<>4
Inkey(0.1)
Enddo
cBody=Strconv(oHttp.responsebody,2)
?Strextract(cBody,'您的IP是:[',']')
Messagebox(Strextract(cBody,[<body style="margin:0px"><center>],[</center></body></html>]))
owsh=Createobject("wscript.shell")
owsh.Run("command.com /c ping -n 1 -r 9 www.163.com >IP.txt",0,.T.)
If File('ip.txt')
If At('Route',Filetostr('ip.txt'))>0
st=Filetostr('ip.txt')
ip=Substr(st,At_c('Route:',st)+6,At_c('->',st)-At_c('Route:',st)-6)
=Messagebox('你的外网:'+ip,64,'获取')
Else
=Messagebox('网络连接失败',48,信息提示')
Endif
Erase ip.txt
Else
=Messagebox('获取失败',48,'信息提示')
Endif