Menampilkan Informasi Network Card

Pada artikel sebelumnya sudah saya share bagaimana cara mendapatkan IP Address dari komputer, silahkan lihat di sini. Berikut ini saya lanjutkan pembahasan mengenai bagaimana mengetahui informasi detail dari network card yang terinstal dikomputer meliputi MAC Address, Informasi DNS, IP Version, dan lain-lain.

OK, Berikut ini codingnya menggunakan VB.NET 2010:

Imports System.Net.NetworkInformation

Public Class FrmGetNetwork

    Private Sub BtnGetInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGetInfo.Click
        ShowNetworkInterfaces()
    End Sub

    Public Sub ShowNetworkInterfaces()
        Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
        Dim nics() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces()

        ListInfo.Items.Clear()
        ListInfo.Items.Add("Computer Name ............... : " & computerProperties.HostName)
        ListInfo.Items.Add("Domain Name ................. : " & computerProperties.DomainName)
        If nics Is Nothing OrElse nics.Length < 1 Then
            ListInfo.Items.Add("No network interfaces found.")
            Return
        End If
        ListInfo.Items.Add("Number of interfaces ........ : " & nics.Length)
        ListInfo.Items.Add("  ")

        Dim i As Integer = 1
        For Each adapter In nics
            Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
            ListInfo.Items.Add(i & ". " & adapter.Description)
            ListInfo.Items.Add(String.Empty.PadLeft(adapter.Description.Length, "="))
            ListInfo.Items.Add(" Interface type" & vbTab & vbTab & adapter.NetworkInterfaceType)
            ListInfo.Items.Add(" Physical Address" & vbTab & vbTab & adapter.GetPhysicalAddress().ToString())
            ListInfo.Items.Add(" Operational status" & vbTab & vbTab & adapter.OperationalStatus)

            Dim versions As String = ""

            ' Create a display string for the supported IP versions.
            If adapter.Supports(NetworkInterfaceComponent.IPv4) Then
                versions = "IPv4"
            End If

            If adapter.Supports(NetworkInterfaceComponent.IPv6) Then
                If versions.Length > 0 Then
                    versions &= " "
                End If
                versions &= "IPv6"
            End If
            ListInfo.Items.Add(" IP version" & vbTab & vbTab & versions)

            ' The following information is not useful for loopback adapters.
            If adapter.NetworkInterfaceType = NetworkInterfaceType.Loopback Then
                Continue For
            End If
            ListInfo.Items.Add(" DNS suffix" & vbTab & vbTab & properties.DnsSuffix)

            Dim label As String
            If adapter.Supports(NetworkInterfaceComponent.IPv4) Then
                Dim ipv4 As IPv4InterfaceProperties = properties.GetIPv4Properties()
                ListInfo.Items.Add(" MTU" & vbTab & vbTab & vbTab & ipv4.Mtu)
                If ipv4.UsesWins Then

                    Dim winsServers As IPAddressCollection = properties.WinsServersAddresses
                    If winsServers.Count > 0 Then
                        label = "WINS Servers"
                    End If
                End If
            End If

            ListInfo.Items.Add(" DNS enabled" & vbTab & vbTab & properties.IsDnsEnabled)
            ListInfo.Items.Add(" Dynamically configured DNS" & vbTab & properties.IsDynamicDnsEnabled)
            ListInfo.Items.Add(" Receive Only" & vbTab & vbTab & adapter.IsReceiveOnly)
            ListInfo.Items.Add(" Multicast" & vbTab & vbTab & vbTab & adapter.SupportsMulticast)

            ListInfo.Items.Add("  ")

            i += 1
        Next adapter

    End Sub
End Class

Hasilnya:

Informasi Network

Selamat Mencoba.., Semoga bermanfaat.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: