怎么样得到mac地址

shkspr 2002-07-22 05:08:27
最好是在9x和nt/2k下兼容的方法
...全文
3 点赞 收藏 1
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lqbn 2002-07-22
ASTAT Adapter;

char output[1000];

NCB Ncb;
UCHAR uRetCode;
LANA_ENUM lenum;
int i;

i=sizeof(Ncb);

memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBENUM;
Ncb.ncb_buffer = (UCHAR *)&lenum;
Ncb.ncb_length = sizeof(lenum);
uRetCode = Netbios( &Ncb );
sprintf(output, "The NCBENUM return code is: 0x%x \n", uRetCode );
m_Edit1 = output;

sprintf(output, "%d", lenum.length);

MessageBox(output);

for(i=0; i < lenum.length ;i++) {
memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBRESET;
Ncb.ncb_lana_num = lenum.lana[i];

uRetCode = Netbios( &Ncb );
sprintf(output, "The NCBRESET on LANA %d return code is: 0x%x \n",lenum.lana[i], uRetCode );
m_Edit2 = output;

memset( &Ncb, 0, sizeof (Ncb) );
Ncb.ncb_command = NCBASTAT;
Ncb.ncb_lana_num = lenum.lana[i];

strcpy( (char*)Ncb.ncb_callname, "* " );
Ncb.ncb_buffer = (unsigned char *) &Adapter;
Ncb.ncb_length = sizeof(Adapter);

uRetCode = Netbios( &Ncb );
printf( "The NCBASTAT on LANA %d return code is: 0x%x \n",lenum.lana[i], uRetCode );
if( uRetCode == 0 ) {
sprintf(output,
"The Ethernet Number on LANA %d is: %02X-%02X-%02X-%02X-%02X-%02X\n",
lenum.lana[i],
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]
);
m_Edit3 = output;
}
m_Edit4 = GetMacAddress("Athlon");
UpdateData(FALSE);
MessageBox("OK");
}
回复
发动态
发帖子
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
社区公告
暂无公告