Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
getinterfaces()
End Sub
Private Sub getinterfaces()
Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
If nics.Length < 0 Or nics Is Nothing Then
MsgBox("네트워크 인터페이스를 찾을수 없습니다")
Exit Sub
End If
ListView1.Items.Clear()
For Each netadapter As NetworkInterface In nics
Dim intproperties As IPInterfaceProperties = netadapter.GetIPProperties()
ListView1.Items.Add(netadapter.Name)
Dim paddress As PhysicalAddress = netadapter.GetPhysicalAddress()
Dim addbyte As Byte() = paddress.GetAddressBytes()
Dim macaddress As String = ""
For i = 0 To addbyte.Length - 1
macaddress &= addbyte(i).ToString("X2")
If i <> addbyte.Length - 1 Then
macaddress &= "-"
End If
Next
Dim icount As Integer = ListView1.Items.Count
Try
With ListView1.Items(icount - 1).SubItems
.Add(macaddress)
.Add(intproperties.UnicastAddresses(2).Address.ToString)
.Add(intproperties.UnicastAddresses(2).IPv4Mask.ToString)
.Add(intproperties.UnicastAddresses(0).Address.ToString)
.Add(intproperties.UnicastAddresses(1).Address.ToString)
End With
Catch ex As Exception
End Try
Next
'ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
End Sub
End Class