如何使用VB.NET获取ListView中连接到网络的所有计算机名称和IP地址,包括(LAN& Wifi)?
答案 0 :(得分:0)
计算机名称:
My.Computer.Name
IP地址(您的计算机可能有多个适配器,每个适配器可以有多个地址):
For Each i As Net.NetworkInformation.NetworkInterface In Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
Dim props As Net.NetworkInformation.IPInterfaceProperties = i.GetIPProperties
For Each addr As Net.NetworkInformation.UnicastIPAddressInformation In props.UnicastAddresses
Debug.WriteLine(addr.Address.ToString)
Next
Next