如何使用vb.net代码识别计算机名称和IP地址? [英] how to identify computer name and ip address using vb.net code?

查看:135
本文介绍了如何使用vb.net代码识别计算机名称和IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人知道吗?

解决方案

检查以下链接:


http://stackoverflow. com/questions/2234757/如何使用vb网络获取计算机的名称和IP地址

http://www.vbforums.com/showthread.php?t=403336

http://www.sumedh.info/downloads/get-ip-username-mac.html

http://www.codeguru.com/cpp/in/network/networkinformation/article. php/c5455


尝试一下

 私有  Dim  strHostName  As  字符串

 Dim  strIPAddress  As  字符串



strHostName = System.Net.Dns.GetHostName()

strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList( 0 ).ToString()


MessageBox.Show(" & strHostName&  ; IP地址:"& strIPAddress)

结束  



要获取IP地址,请尝试以下操作

 字符串 myHost = System.Net.Dns.GetHostName();
            System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);
             foreach (System.Net.IPAddress myIP  in  myIPs.AddressList中)
            {
                TextBox1.Text = myIP.ToString();
            } 



另一种选择是

 选项 严格 关闭
导入系统
导入 System.Net.DNS
公共  GetIP
共享 功能 GetIPAddress() As  字符串
 Dim  sam  As  System.Net.IPAddress
 Dim  sam1  As  字符串
使用 system.Net.DNS.GetHostByName(system.Net.DNS.GetHostName())
    sam = 新建 System.Net.IPAddress(.AddressList( 0 ).Address)
    sam1 = sam.ToString
结束 使用
GetIPAddress = sam1
结束 功能
    共享  Sub  main()
       Dim 主机名 As   String 
      shostname = system.Net.DNS.GetHostName
      console.writeline(" & shostname)
      console.writeline(" & GetIPAddress)
    结束 
 结束  



希望这会为您提供帮助


在远程计算机上,正在运行代码的本地计算机上,还是从与应用程序的传入连接中?


hi,

Can anyone know?

how to identify computer name and ip address using vb.net code?

解决方案

Check following Links :


http://stackoverflow.com/questions/2234757/how-do-i-get-a-computers-name-and-ip-address-using-vb-net

http://www.vbforums.com/showthread.php?t=403336

http://www.sumedh.info/downloads/get-ip-username-mac.html

http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5455


Try This

Private Sub GetIPAddress()

Dim strHostName As String

Dim strIPAddress As String



strHostName = System.Net.Dns.GetHostName()

strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()


MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress)

End Sub



To Get Just The IP Address Try the following

string myHost = System.Net.Dns.GetHostName();
            System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);
            foreach (System.Net.IPAddress myIP in myIPs.AddressList)
            {
                TextBox1.Text = myIP.ToString();
            }



One More Option Is

Option Strict Off
Imports system
Imports System.Net.DNS
Public Class GetIP
Shared Function GetIPAddress() As String
Dim sam As System.Net.IPAddress
Dim sam1 As String
With system.Net.DNS.GetHostByName(system.Net.DNS.GetHostName())
    sam = New System.Net.IPAddress(.AddressList(0).Address)
    sam1 = sam.ToString
End With
GetIPAddress = sam1
End Function
    Shared Sub main()
      Dim shostname As String
      shostname = system.Net.DNS.GetHostName
      console.writeline("Name of the System is = " & shostname)
      console.writeline("Your IP address is= " & GetIPAddress)
    End Sub
 End Class



Hope this will help you


Of a remote machine, the local machine the code is running on, or from an incoming connection to your application??


这篇关于如何使用vb.net代码识别计算机名称和IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆