大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
做exe程序获取本机IP地址用
创新互联是一家专注于网站制作、成都网站设计与策划设计,金平网站建设哪家好?创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:金平等地区。金平做网站价格咨询:028-86922220
System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList
做web程序获取客户端的IP地址用
HttpContext.Current.Request.ServerVariables("REMOTE_ADDR"])
Dim IPAdress As System.Net.IPAddress
HostName = System.Net.Dns.GetHostName '获得本机的机器名
IPAdress = System.Net.Dns.GetHostByName(HostName).AddressList.GetValue(0) '获得本机的IP
Me.TextBox1.Text = HostName '本机机器名
Me.TextBox2.Text = IPAdress.ToString '本机的IP
定义以下过程即可获取本机ip地址
Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = "."
Set objWMI = GetObject("winmgmts://" strComputer "/root/cimv2")
Set colIP = objWMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNull(IP.IPAddress) Then
For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)
MsgBox "IP 地址:" IP.IPAddress(I) Chr(10) _
Next
End If
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cc() As System.Net.IPAddress = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList
Dim str As String = ""
For Each ws In cc
str = str ws.ToString vbCrLf
Next
MsgBox(str)
End Sub