Click to See Complete Forum and Search --> : How Can I get Ethernet Card 48bits Address?


May 17th, 1999, 06:42 AM
How Can I get Ethernet Card 48bits Address? Who can Tell me.

May 17th, 1999, 09:29 AM
I have the same need including the necessity to run both 95/98 and NT

May 31st, 1999, 03:27 AM
I have found this using the Netbios API. This needs to link with NETAPI32.LIB and to have the Netbios protocol running on the target machine.

Here is a sample code (gets from the MSDN search engine)


#include <windows.h>
#include <wincon.h>
#include <nb30.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

typedef struct _ASTAT_
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
} ASTAT;


void main (void)
{
ASTAT Adapter;
NCB Ncb;
UCHAR uRetCode;
LANA_ENUM lenum;
int i;
CString tmp;

memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBENUM;
Ncb.ncb_buffer = (UCHAR *)&lenum;
Ncb.ncb_length = sizeof(lenum);
uRetCode = Netbios( &Ncb );

if (uRetCode != 0)
{
tmp.Format("The NCBENUM return code is: 0x%x \n", uRetCode );
AfxMessageBox(tmp);
return;
}

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 );

if (uRetCode != 0)
{
tmp.Format("The NCBRESET on LANA %d return code is: 0x%x \n", lenum.lana[i], uRetCode);
AfxMessageBox(tmp);
continue;
}

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 );

if (uRetCode != 0)
{
tmp.Format("The NCBASTAT on LANA %d return code is: 0x%x \n", lenum.lana[i], uRetCode);
AfxMessageBox(tmp);
continue;
}
else
{
tmp.Format("Ethernet 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]
);

AfxMessageBox(tmp);
}
}
}





Hope this help.

rohitacharya
May 31st, 1999, 03:32 AM
use the 16 char to Right hand side of classID created by UIDGEN utility locally on that machine which u need to find the MAC address