Tient voila une méthode qui marche bien.
int Get_adresseMac(int numeroInterface, char * adrMAC)
{
NCB Ncb;
LANA_ENUM lenum;
memset ( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBENUM;
Ncb.ncb_buffer = (UCHAR *)&lenum;
Ncb.ncb_length = sizeof(lenum);
Netbios( &Ncb);
if (numeroInterface <= lenum.length)
{
memset (&Ncb, 0, sizeof(Ncb));
Ncb.ncb_command = NCBRESET;
Ncb.ncb_lana_num = lenum.lana[numeroInterface];
Netbios(&Ncb);
memset (&Ncb, 0,sizeof(Ncb));
Ncb.ncb_command = NCBASTAT;
Ncb.ncb_lana_num = lenum.lana[numeroInterface];
strcpy (Ncb.ncb_callname, "* " );
Ncb.ncb_buffer = (char *) &Adapter;
Ncb.ncb_length = sizeof(Adapter);
if (Netbios(&Ncb) ==0)
{
sprintf(adrMAC, "%02x%02x%02x%02x%02x%02x",
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 OK;
}
else
return NOK;
}
else
return NOK;
}
++