快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb点虐 获取公网ip vb获取网卡物理地址

VB2013,VB点虐 外网IP获取问题!

直接对服务器请求。(该服务器要有相对的功能,连线后控件属性即包含,可设置自动回报)

在鸡西梨树等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站设计制作、做网站 网站设计制作按需制作,公司网站建设,企业网站建设,品牌网站建设,营销型网站建设,外贸网站制作,鸡西梨树网站建设费用合理。

找一个网页,内容含有显示浏览者ip的网址。抓该网页的内容分析获取外网的字串。

提供一个安全网址给你:

是APNIC亚洲数据中心的首页 的子页

vb 如何获取外网ip

vb 如何获取外网ip代码:

'获取公网IP

Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" ( _

ByVal sAgent As String, ByVal lAccessType As Long, _

ByVal sProxyName As String, ByVal sProxyBypass As String, _

ByVal lFlags As Long) As Long

Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" ( _

ByVal hInternetSession As Long, ByVal sUrl As String, _

ByVal sHeaders As String, ByVal lHeadersLength As Long, _

ByVal lFlags As Long, ByVal lContext As Long) As Long

Private Declare Function InternetReadFile Lib "wininet.dll" ( _

ByVal hFile As Long, ByVal sBuffer As String, _

ByVal lNumBytesToRead As Long, _

lNumberOfBytesRead As Long) As Integer

Private Declare Function InternetCloseHandle Lib "wininet.dll" ( _

ByVal hInet As Long) As Integer

Private Const INTERNET_FLAG_NO_CACHE_WRITE = H4000000

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

Public Function GetSub() As String

Dim wburl$, wburl2$, X1, X2, X3, X4

On Error GoTo err

wburl = ""

wburl = GetUrlFile(wburl)

If InStr(1, wburl, "无法找到该页") = 0 Then

X1 = InStr(1, wburl, "[")

X2 = InStr(1, wburl, "]")

X1 = Mid(wburl, X1, X2 - X1)

X1 = Replace(X1, "[", "")

X1 = Replace(X1, " ", "")

X1 = Replace(X1, vbCrLf, "")

GetSub = X1

Exit Function

End If

wburl2 = ""

wburl2 = GetUrlFile(wburl2)

If InStr(1, wburl2, "无法找到该页") = 0 Then

X3 = InStr(1, wburl2, "h2")

X4 = InStr(1, wburl2, "/h2")

X3 = Mid(wburl2, X3, X4 - X3)

X3 = Replace(X3, "h2", "")

X3 = Replace(X3, " ", "")

X3 = Replace(X3, vbCrLf, "")

GetSub = X3

Exit Function

Else

GetSub = "127.0.0.1"

End If

err:

GetSub = "127.0.0.1"

End Function

Private Function GetUrlFile(stUrl As String) As String

Dim lgInternet As Long, lgSession As Long

Dim stBuf As String * 1024

Dim inRes As Integer

Dim lgRet As Long

Dim stTotal As String

stTotal = vbNullString

lgSession = InternetOpen("VBTagEdit", 1, vbNullString, vbNullString, 0)

If lgSession Then

lgInternet = InternetOpenUrl(lgSession, stUrl, vbNullString, _

0, INTERNET_FLAG_NO_CACHE_WRITE, 0)

If lgInternet Then

Do

inRes = InternetReadFile(lgInternet, stBuf, 1024, lgRet)

stTotal = stTotal Mid$(stBuf, 1, lgRet)

Loop While (lgRet 0)

End If

inRes = InternetCloseHandle(lgInternet)

End If

GetUrlFile = stTotal

End Function

使用方法:

在form中调用GetSub就行了。

List1.AddItem ("公网IP:" GetSub + "..")。

VB.NET2010 怎么获取IP

1.获取当前电脑名:System.Net.Dns.GetHostName()

2.根据电脑名取出全部IP地址:System.Net.Dns.Resolve(电脑名).AddressList

或者 System.Net.Dns.GetHostByName(电脑名).AddressList

3.根据IP地址取出电脑名:System.Net.Dns.Resolve(IP地址).HostName

VB点虐 2015 如何获取外网IP并保存到软件目录下的IP.txt文件

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

Dim str As String

str = Me.WebBrowser1.Document.Body.InnerHtml

Dim a As Integer = 0

Dim b As Integer = 0

a = InStr(str, "[")

b = InStr(str, "]")

TextBox1.Text = Mid(str, a + 1, b - a - 1)

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Me.WebBrowser1.Navigate("

)

End Sub

End Class

网页上显示的有点问题,form1_load 中代码是:Me.WebBrowser1.Navigate("")

原理:访问查IP网页后,获取网页上显示的本机外网ip地址


名称栏目:vb点虐 获取公网ip vb获取网卡物理地址
文章链接:http://6mz.cn/article/ddsdecd.html

其他资讯