vc 6ネイティブのすべてのmacアドレスを取得
ダイアログプログラムを作成し、project/setting/linkにnetapi 32を追加します.lib
1.includeヘッダファイル
3.メンバー関数の追加
4、ボタンを追加します.ボタンイベント関数は
1.includeヘッダファイル
#include < nb30.h >
2.変数の追加typedef struct _ASTAT_
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
}ASTAT, * PASTAT;
ASTAT Adapter;
3.メンバー関数の追加
void CRegisterDlg::getmac_one(int lana_num)
{
NCB ncb;
UCHAR uRetCode;
memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBRESET;
ncb.ncb_lana_num = lana_num;//
// NCBRESET ,
uRetCode = Netbios( &ncb );
printf( "The NCBRESET return code is:0x%x
", uRetCode );
memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBASTAT;
ncb.ncb_lana_num = lana_num; //
strcpy( (char *)ncb.ncb_callname,"* " );
ncb.ncb_buffer = (unsigned char *) &Adapter;//
ncb.ncb_length = sizeof(Adapter);
// , NCBASTAT
uRetCode = Netbios( &ncb );
printf( "The NCBASTAT return code is: 0x%x
", uRetCode );
if ( uRetCode == 0 )
{
// MAC 16 , 0010-A4E4-5802
TRACE( "The Ethernet Number[%d] is: %02X%02X-%02X%02X-%02X%02X
",
lana_num,
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] );
}
}
4、ボタンを追加します.ボタンイベント関数は
void CRegisterDlg::OnRegister()
{
NCB ncb;
UCHAR uRetCode;
LANA_ENUM lana_enum;
memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBENUM;
ncb.ncb_buffer = (unsigned char *) &lana_enum;
ncb.ncb_length = sizeof(lana_enum);
// NCBENUM , , 、
uRetCode = Netbios( &ncb );
printf( "The NCBENUM return code is: 0x%x
", uRetCode );
if ( uRetCode == 0 )
{
TRACE( "Ethernet Count is : %d
", lana_enum.length);
// , , MAC
for ( int i=0; i< lana_enum.length; ++i)
getmac_one( lana_enum.lana[i]);
}
}