SendARP

C# Signature:

[DllImport("iphlpapi.dll", ExactSpelling=true)]
  public static extern int SendARP( 
      uint DestIP, uint SrcIP, byte[] pMacAddr, ref int PhyAddrLen);

VB Signature:

Declare Function SendARP Lib "iphlpapi.dll" (
      ByVal DestIP As UInt32, ByVal SrcIP As UInt32, _
      ByVal pMacAddr As Byte(), ByRef PhyAddrLen As Integer) As Integer

Sample Code:

Public Shared Function GetMAC(ByVal IPAddress A

    Dim addr As IPAddress = IPAddress.Parse(IPAddress)
    Dim mac() As Byte = New Byte(6) {}
    Dim len As Integer = mac.Length
    SendARP(CType(addr.Address, UInt32), 0, mac, len)
    Dim macAddress As String = BitConverter.ToString(mac, 0, len)
    Return macAddress

End Function

Sample Code:

Alternative Managed API:

Última actualización