Write how to obtain remote IP, Mac with C #

xiaoxiao2021-03-06  67

If you want to get a remote address, you need to use the Sendarp function. The specific code is as follows: [DLLIMPORT ("iPhlPapi.dll")] Private Static Unsafe Extern Int Sendarp (INT32 DEST, INT32 HOST, Ref INTPTPTR MAC, Ref INTPTR LENGTH); [DLLIMPORT ("WS2_32.dll")] Private static extern INT32 INET_ADDR (String IP); INT32 LDEST = INET_ADDR ("157.60.68.163"); // Destination IPINT32 LHOST = INET_ADDR ("157.60.68.33"); // Local iptry {byte [] MacInfo = New Byte [ 6]; INT32 Length = 6; INTPTR MAC = New INTPTR (Macinfo [0]); INTPTR LEN = New INTPTR (6); INT II = Sendarp (LDest, Lhost, Ref Mac, Ref Len); console.writeline Mac Add: " Mac); Console.Writeline (" Length: " LEN);} catch (exception err) {console.writeline (ERR);

转载请注明原文地址:https://www.9cbs.com/read-94689.html

New Post(0)