Try this one, I got it off of a website, but I don't know whick one. There are 1 other methods of finding it if this one doesn't work. Just tell me if you need them. It might get a little confusing if I stick all three methods in.
// Get the adapter's info and, if this works, return it in standard,
// colon-delimited form.
if (Netbios(&Ncb) == 0) {
char acMAC[18];
sprintf(acMAC, "%02X:%02X:%02X:%02X:%02X:%02X",
int (Adapter.adapt.adapter_address[0]),
int (Adapter.adapt.adapter_address[1]),
int (Adapter.adapt.adapter_address[2]),
int (Adapter.adapt.adapter_address[3]),
int (Adapter.adapt.adapter_address[4]),
int (Adapter.adapt.adapter_address[5]));
sMAC = acMAC;
return true;
}
else {
char acTemp[80];
ostrstream outs(acTemp, sizeof(acTemp));
outs << "error " << Ncb.ncb_retcode << " on ASTAT" << ends;
sMAC = acTemp;
return false;
}
}
int main()
{
// Get adapter list
LANA_ENUM AdapterList;
NCB Ncb;
memset(&Ncb, 0, sizeof(NCB));
Ncb.ncb_command = NCBENUM;
Ncb.ncb_buffer = (unsigned char *)&AdapterList;
Ncb.ncb_length = sizeof(AdapterList);
Netbios(&Ncb);
// Get all of the local ethernet addresses
string sMAC;
for (int i = 0; i < AdapterList.length; ++i) {
if (GetAdapterInfo(AdapterList.lana, sMAC)) {
cout << "Adapter " << int (AdapterList.lana) <<
"'s MAC is " << sMAC << endl;
}
else {
cerr << "Failed to get MAC address! Do you" << endl;
cerr << "have the NetBIOS protocol installed?" << endl;
break;
}
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.