Sendarp
31 indicates that the other party does not boot, our function does not detect it,
1784 the value of the last argument to the function is 0, or your given value does not match the buffer size you gave.
If return 31 is not a line, the last parameter pointer points to a value of 0
The function has one drawback :
This function essentially sends an ARP request packet to the target host and then gets the reply packet to update the MAC, but the send-side IP and Mac in the ARP Request packet are native IP and Mac, so the other side arp-a to view the cache table with my Ip-mac mapping record in the record. It is easy to know if someone is scanning their machine, or the ARP virus is also possible.
The problem with solving this function is to forge the package yourself, but the MAC address must be correct, otherwise the reply packet will not be sent to the native ~
UpdateData (TRUE); if (M_straddr.isempty ()) {AfxMessageBox ("Please fill in the host IP address to find the MAC address"); Return } unsigned long uladdr = inet_addr (M_STRADDR); unsigned long ulmac[2]; unsigned long ullen = 6; DWORD Dwretval =Sendarp(uladdr, 0, Ulmac, &ullen); if (Dwretval = = no_error) {size_t I, J; char * Szmac = new Char[ullen*3]; Pbyte Pbhexmac = (pbyte) Ulmac; for (i = 0, j = 0; i < ulLen-1; ++i) {J + = sprintf (Szmac + J, "%02x:", Pbhexmac[i]); } sprintf (Szmac + J, "%02x", Pbhexmac[i]); M_strmac = Szmac; delete [] Szmac; } updatedata (FALSE);
Get the MAC address of the LAN computer using the function Sendarp ()