CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    7

    MAC-number of network card



    Hello,


    I want to determine the unique 48-bit long MAC-number of a network card.

    I've searched the Win32-Winsocket-API, but I couldn't find something

    useful to read the number.


    Best regards

    Andy



  2. #2
    Join Date
    Jun 2001
    Location
    India
    Posts
    14

    Re: MAC-number of network card

    Hi,


    This information has been provided in the microsoft support site


    #include <windows.h>
    #include <wincon.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <time.h>
    #include <Nb30.h>
    typedef struct _ASTAT_
    {

    ADAPTER_STATUS adapt;
    NAME_BUFFER NameBuff [30];

    }ASTAT, * PASTAT;

    ASTAT Adapter;

    void main (void)
    {
    NCB Ncb;
    UCHAR uRetCode;
    char NetName[50];
    LANA_ENUM lenum;
    int i;

    memset( &Ncb, 0, sizeof(Ncb) );
    Ncb.ncb_command = NCBENUM;
    Ncb.ncb_buffer = (UCHAR *)&lenum;
    Ncb.ncb_length = sizeof(lenum);
    uRetCode = Netbios( &Ncb );
    printf( "The NCBENUM return code is: 0x%x \n", uRetCode );

    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 );
    printf( "The NCBRESET on LANA %d return code is: 0x%x \n",
    lenum.lana[i], uRetCode );

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

    }
    }

    }





    In the project settings add netapi32.lib in Link Oject Library MOdule



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