Get a remote network card MAC address.

zhaozj2021-02-11  233

First, add #include "nb30.h" #pragma Comment (lib, "netapi32.lib") typefma command (lib); name_buffer namebuff [30];} ASTAT, * PASTAT;

You can use it to get the remote network card MAC address: CString getMacadDress (cstring snetbiosname) {Astat Adapter; NCB NCB; Uchar uretcode; MEMSET (& NCB, 0, SIZEOF (NCB)); ncb.ncb_command = ncbreset; ncb.ncb_lana_num = 0; uRetCode = Netbios (& ncb); memset (& ncb, 0, sizeof (ncb)); ncb.ncb_command = NCBASTAT; ncb.ncb_lana_num = 0; sNetBiosName.MakeUpper (); FillMemory (ncb.ncb_callname, NCBNAMSZ - 1, 0x20 ); strcpy ((char *) ncb.ncb_callname, (LPCTSTR) sNetBiosName); ncb.ncb_callname [sNetBiosName.GetLength ()] = 0x20; ncb.ncb_callname [NCBNAMSZ] = 0x0; ncb.ncb_buffer = (unsigned char *) & Adapter Ncb.ncb_length = sizeof (adapter); uretcode = netbios (& NCB); cstring smacaddress; if (uretcode == 0) {smacaddress.format (_T ("% 02x% 02x% 02x% 02x% 02x% 02x"), Adapter.adapt.adapter_address [0], adapter.adapt.adapter_address [1], adapter.adapt.adapter_address [2], adapter.adapt.adapter_address [3], Adapter.Adapt.adapter _address [4], adapter.adapt.adapter_address [5]);} Return Smacaddress;}

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

New Post(0)