主题:关于使用Netbios来获取无线网卡Mac地址的问题
请问各位高手,使用Netbios来获取无线网卡Mac地址时,获取失败,跟踪发觉以下红色值为5'|',而正常应该是0,到底为什么呢?万分感谢阿!!
以下是源码:
主要函数1:
void CBasicDlg::OnBnClickedMac()
{
// TODO: 在此添加控件通知处理程序代码
LPCTSTR kb;
NCB ncb;
CGetNetInfo getnetinfo;
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);
uRetCode = Netbios(&ncb);
ASTAT adapter;
if(uRetCode == 0)
{
for(int i = 0;i<lana_enum.length;i++)
{
kb = getnetinfo.GetMacAddress(lana_enum.lana[i],adapter);
}
}
GetDlgItem(IDC_EDIT_MAC)->SetWindowText(kb);
}
主要函数2:
LPCTSTR CGetNetInfo::GetMacAddress(int lana_num,ASTAT &adapter)
{
NCB ncb;
UCHAR uRetCode;
memset(&ncb,0,sizeof(ncb));
ncb.ncb_command = NCBRESET;
ncb.ncb_lana_num = lana_num;
uRetCode = Netbios( &ncb );
memset(&ncb,0,sizeof(ncb));
ncb.ncb_command = NCBASTAT;
ncb.ncb_lana_num = lana_num;
ncb.ncb_buffer = (unsigned char*)&adapter;
ncb.ncb_length = sizeof(adapter);
uRetCode = Netbios( &ncb );
if(uRetCode == 0)
{
m_MacAddr[lana_num].b1 = adapter.adapt.adapter_address[0];
m_MacAddr[lana_num].b2 = adapter.adapt.adapter_address[1];
m_MacAddr[lana_num].b3 = adapter.adapt.adapter_address[2];
m_MacAddr[lana_num].b4 = adapter.adapt.adapter_address[3];
m_MacAddr[lana_num].b5 = adapter.adapt.adapter_address[4];
m_MacAddr[lana_num].b6 = adapter.adapt.adapter_address[5];
}
CString strMac;
strMac.Format(m_MacAddr[lana_num].b1, m_MacAddr[lana_num].b2, m_MacAddr[lana_num].b3, m_MacAddr[lana_num].b4, m_MacAddr[lana_num].b5, m_MacAddr[lana_num].b6);
LPCTSTR kb = (LPCTSTR)strMac;
return kb;
}
一直都没问题,就是到了红色部分该值为5'|',而不是0,到底为什么呢?谢谢!