获取所有IPV4连接的vb.net

时间:2017-06-05 22:47:41

标签: vb.net

我正在尝试从我的Lan Connection获取所有IPV4和我的路由器,但我只是接收了自己的IPV4。

有一个API可以做到吗?

我试过这样的事情:

 Sub GetIps()
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In adapters
        Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
        If properties.UnicastAddresses.Count > 0 Then
            For Each unicastadress As UnicastIPAddressInformation In properties.UnicastAddresses
                Dim ip As IPAddress = unicastadress.Address
                If ip.AddressFamily = AddressFamily.InterNetwork Then
                    MsgBox(ip.ToString)
                End If
            Next unicastadress
        End If
    Next adapter
End Sub

0 个答案:

没有答案