Description:
Code
This Displays MAC Address, add 1 textbox call it MacLocalIPAddressBox and one label called MACAddressDisplayLabel. Then all you need to do is add the code below
and add local machines ip addresss ie 192.168.1.1 then press the button and the label will display the mac address for each local machines ip.Declarations:
Code
Declare Function SendARP Lib "iphlpapi.dll" Alias "SendARP" (ByVal DestIP As Int32, ByVal SrcIP As Int32, ByVal pMacAddr() As Byte, ByRef PhyAddrLen As Int32) As Int32Code:
Code
Public Shared Function GetMac(ByVal ipAddr As String) As String
Dim macAddress As String = String.Empty
Try
Dim destIP As Net.IPAddress = Net.IPAddress.Parse(ipAddr)
Dim IP() As Byte = destIP.GetAddressBytes()
Dim IPInt As Int32 = BitConverter.ToInt32(IP, 0)
Dim mac() As Byte = New Byte(5) {}
SendARP(IPInt, 0, mac, mac.Length)
macAddress = BitConverter.ToString(mac, 0, mac.Length)
Catch ex As Exception
Debug.Write(ex.Message)
End Try
Return macAddress
End FunctionUsage:
Code
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
Me.MACAddressDisplayLabel.Text = GetMac(Me.MacLocalIPAddressBox.Text)
End SubI Hope This helped you all.
-NathanE
PHP & .NET Contributor.

