Jump to content

Obter endereço de IP


Hitmanpt
 Share

Recommended Posts

Boas pessoal, eu tenho andado a tentar obter o endereço de IP para cada placa de rede mas não tenho tido sucesso 😉

Aqui está o meu código

Dim iface As NetworkInterface() = GetAllInterfaces()
        Dim i As Integer = 0
        For Each Str As NetworkInterface In iface
            Dim itm As New ListViewItem(i)
            itm.SubItems.Add(Str.Name)
            itm.SubItems.Add(Str.Description)
            itm.SubItems.Add(Str.GetIPProperties().UnicastAddresses(0).Address.ToString)
            ListView1.Items.Add(itm)
            i = i + 1
        Next

Prece-me estar tudo OK mas na parte dos IP's aparece-me isto

http://hitman-pt.zzl.org/help/Untitled.png

Link to comment
Share on other sites

Sacar IP's

Public Function GetIp() As String
       Try
            Dim IPList As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName)
            Dim IP As IPAddress
            For Each IP In IPList.AddressList
                'Only return IPv4 routable IPs
                If (IP.AddressFamily = Sockets.AddressFamily.InterNetwork) Then
                    Return IP.ToString
                End If
            Next
            Return ""
        Catch ex As Exception
          
        End Try
    End Function

depois e so representares....

EDIT: GeSHi adicionado

Quando te pedirem peixe.... ensina-os a Pescar!!Hum..lálálálá!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.