On what OS/Compiler? The following works on MSVC6
Code:#include "stdafx.h" // Obtain the Media Access Control Address (MAC) // needs netapi32.lib #include <windows.h> #include <nb30.h> #include <stdio.h> #include <tchar.h> typedef struct _ASTAT_ { ADAPTER_STATUS adapt; NAME_BUFFER NameBuff [30]; }ASTAT, * PASTAT; ASTAT Adapter; int _tmain(int argc, _TCHAR* argv[]) { NCB ncb; BYTE bRetCode; memset( &ncb, 0, sizeof(ncb) ); ncb.ncb_command = NCBRESET; ncb.ncb_lana_num = 0; bRetCode = Netbios( &ncb ); _tprintf( _T("The NCBRESET return code is: 0x%x \n"), bRetCode ); memset( &ncb, 0, sizeof(ncb) ); ncb.ncb_command = NCBASTAT; ncb.ncb_lana_num = 0; // Must be in non-unicode strcpy( (char*) ncb.ncb_callname, "* " ); ncb.ncb_buffer = (unsigned char *) &Adapter; ncb.ncb_length = sizeof(Adapter); bRetCode = Netbios( &ncb ); _tprintf( _T("The NCBASTAT return code is: 0x%x \n"), bRetCode ); if ( bRetCode == 0 ) { _tprintf( _T("The MAC Address is: %02x%02x%02x%02x%02x%02x\n"), 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; }




Reply With Quote