我希望通过链接获得WanIp [英] I want to get WanIp through the link
本文介绍了我希望通过链接获得WanIp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想从网站上获取wan IP。我试过但它没有显示IP。我也不想要html标签,只有我想要的IP地址我想要
这是我的代码。
Hello I want to get the wan IP from the website.I tried but it doesn't show the IP.Also I don't want the html tags,only the IP address I want that i want
Here is my code.
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Dim cTemp As String
Dim arTemp() As String
Call URLDownloadToFile(0, "http://www.whatismyip.com", App.Path & "\ipaddress.htm", 0, 0)
If Dir(App.Path & "\ipaddress.htm") <> "" Then
cTemp = CreateObject("Scripting.FileSystemObject").OpenTextFile(App.Path & "\ipaddress.htm").ReadAll
If InStr(cTemp, "<h1>") > 0 Then
arTemp = Split(Replace(cTemp, "</h1>", "<h1>"), "<h1>")
MsgBox arTemp(1)
Else
MsgBox "Unknown IP Address"
End If
Kill App.Path & "\ipaddress.htm"
Else
MsgBox "Unknown IP Address"
End If
我还需要一个代码,在连接时将客户端IP更改为服务器IP。
请帮助我..
谢谢
Also I need a code that will change the client ip to server ip when connected.
Please help me..
Thank you
推荐答案
获取客户端IP很简单:HttpContext.Current.Request.UserHostAddress
会直接给你。
获取网站IP地址稍微复杂一点: http://www.howtogeek.com/howto/programming/get-ip-address-from-dns-hostname-in- c / [ ^ ] - 它在C#中,但它非常明显!
您无法更改客户端IP地址 - 它不会发布到你或你控制的任何东西。如果没有别的,如果你可以改变它,你将无法回复用户......
Get the client IP is easy:HttpContext.Current.Request.UserHostAddress
will give it to you directly.
Getting the website IP address is only slightly more complex: http://www.howtogeek.com/howto/programming/get-ip-address-from-dns-hostname-in-c/[^] - it's in C#, but it's pretty obvious!
You cannot change the client IP address - it is not issued to you or by anything you have control over. If nothing else, if you could change it, you wouldn't be able to respond to the user...
这篇关于我希望通过链接获得WanIp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文