如何使用VB.NET在ListView中获取所有计算机的名称和IP地址?

时间:2015-05-20 07:05:21

标签: vb.net networking

如何使用VB.NET获取ListView中连接到网络的所有计算机名称和IP地址,包括(LAN& Wifi)?

1 个答案:

答案 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