# Include "stdafx. H"
# Include <stdio. h>
# Include <stdlib. h>
# Include # Include <windef. h>
# Include <nb30.h>
# Pragma comment (Lib, "netapi32.lib ")
Int getmac (char * Mac)
{
NCB;
Typedef struct _ astat _
{
Adapter_status adapt;
Name_buffer namebuff [30];
} Astat, * pastat;
Astat adapter;
Typedef struct _ lana_enum
{// Le
Uchar length;
Uchar Lana [max_lana];
} Lana_enum;
Lana_enum;
Uchar uretcode;
Memset (& NCB, 0, sizeof (NCB ));
Memset (& lana_enum, 0, sizeof (lana_enum ));
NCB. ncb_command = ncbenum;
NCB. ncb_buffer = (unsigned char *) & lana_enum;
NCB. ncb_length = sizeof (lana_enum );
Uretcode = NetBIOS (& NCB );
If (uretcode! = Nrc_goodret)
Return uretcode;
For (INT Lana = 0; Lana <lana_enum.length; Lana ++)
{
NCB. ncb_command = ncbreset;
NCB. ncb_lana_num = lana_enum.lana [Lana];
Uretcode = NetBIOS (& NCB );
If (uretcode = nrc_goodret)
Break;
}
If (uretcode! = Nrc_goodret)
Return uretcode;
Memset (& NCB, 0, sizeof (NCB ));
NCB. ncb_command = ncbastat;
NCB. ncb_lana_num = lana_enum.lana [0];
Strcpy (char *) NCB. ncb_callname ,"*");
NCB. ncb_buffer = (unsigned char *) & adapter;
NCB. ncb_length = sizeof (adapter );
Uretcode = NetBIOS (& NCB );
If (uretcode! = Nrc_goodret)
Return uretcode;
Sprintf (MAC, "% 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 0;
}
Int main (INT argc, char * argv [])
{
Char Mac [200];
Getmac (MAC );
Printf ("Mac: % s/n", Mac );
Return 0;
}