First, add # include "nb30.h" to the header file definition"
# Pragma comment (Lib, "netapi32.lib ")
Typedef struct _ astat _
{
Adapter_status adapt;
Name_buffer namebuff [30];
} Astat, * pastat;
You can call this operation to obtain the MAC address of the remote NIC:
Cstring getmacaddress (cstring snetbiosname)
{
Astat adapter;
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;
}