CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    How Can I get Ethernet Card 48bits Address?

    How Can I get Ethernet Card 48bits Address? Who can Tell me.


  2. #2
    Guest

    Re: How Can I get Ethernet Card 48bits Address?

    I have the same need including the necessity to run both 95/98 and NT



  3. #3
    Guest

    Re: How Can I get Ethernet Card 48bits Address?

    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.


  4. #4
    Join Date
    May 1999
    Posts
    1

    Re: How Can I get Ethernet Card 48bits Address?

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured