Public class classnetgetmac {public classnetgetmac () {}
[DllImport ( "Iphlpapi.dll")] private static extern int SendARP (Int32 dest, Int32 host, byte [] mac, ref Int32 length); [DllImport ( "Ws2_32.dll")] private static extern Int32 inet_addr (string ip );
/// /// Get a network card MAC address /// summary> /// given the IP address param> /// corresponding IP NIC MAC Address RETURns> Public Static String getMacByip (String IP) {Try {byte [] AA = New Byte [6];
INT32 LDEST = INET_ADDR (IP); // Destination IP
INT64 MacInfo = New INT64 (); int32 len = 6; int res = sendarp (LDEST, 0, AA, REF LEN);
Return Bitconverter.Tostring (AA, 0, 6) ;; Catch (Exception Err) {throw Err;}}
}