[DllImport ( "Iphlpapi.dll")] private static extern int SendARP (Int32 dest, Int32 host, ref Int64 mac, ref Int32 length); [DllImport ( "Ws2_32.dll")] private static extern Int32 inet_addr (string ip) ;
Static Private INT64 GetRemoteMac (String localip, string remoteip) {INT32 LDEST = inet_addr (remoteip); // Destination IP INT32 LHOST = INET_ADDR (localip); // Local Server IP
Try {int64 macinfo = new int64 (); int32 len = 6; int res = sendarp (LDEST, 0, REF MACINFO, REF LEN); RETURN MACINFO;} catch (Exception Err) {Console.Writeline ("error: {0 } ", err.message);} return 0;}