delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/09/01/03:36:00

From: craig AT reversion DOT ca (Craig Nelson)
Subject: Looking for Enet Addr: netbios not in netapi32
1 Sep 1998 03:36:00 -0700 :
Message-ID: <199808311559.JAA03640.cygnus.gnu-win32@tuffy.reversion.ca>
To: gnu-win32 AT cygnus DOT com

Howdy Folks!

I have a piece of code here that gets the ethernet address from a machine using
the Netbios function.  I've seen similar programs out there (almost exactly) but
I can't find the Netbios call in the netapi32 library supplied with B19.1.

Also missing is the definitions for NCBRESET and NCBASTAT, but from other
sources, I've managed to figure out that they are 0x32 and 0x33 respectively,
so I've defined them myself just to get the program to compile.

Alas, the Netbios function call remains undefined.  'nm' shows nothing with the exact name "Netbios" and 'strings' shows exactly that somewhere in the .a

I believe the code will compile using MSVC++ 5.0, but haven't a copy to prove
it.  

Can anyone get this thing to work??  Is there a better way?

Thanks for your reply...

Craig Nelson, Cameo Systems Inc.
craig AT reversion DOT ca


---------- start of code --------

#include <windows.h>
#include <wincon.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
// #include <nb30.h>  // some other programs include this. It isn't found anyway

// Define the missing..
#define NCBRESET 0x32
#define NCBASTAT 0x33

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

ASTAT Adapter;

void main (void)
{
        NCB Ncb;
        UCHAR uRetCode;
        char NetName[50];

        memset( &Ncb, 0, sizeof(Ncb) );
        Ncb.ncb_command = NCBRESET;
        Ncb.ncb_lana_num = 0;

        uRetCode = Netbios( &Ncb );
        printf( "The NCBRESET return code is: 0x%x \n", uRetCode );

        memset( &Ncb, 0, sizeof (Ncb) );
        Ncb.ncb_command = NCBASTAT;
        Ncb.ncb_lana_num = 0;

        strcpy( Ncb.ncb_callname,  "*               " );
        Ncb.ncb_buffer = (char *) &Adapter;
        Ncb.ncb_length = sizeof(Adapter);

        uRetCode = Netbios( &Ncb );
        printf( "The NCBASTAT return code is: 0x%x \n", uRetCode );
        if ( uRetCode == 0 ) {
                printf( "The Ethernet Number is: %02x.%02x.%02x.%02x.%02x.%02x\n",
                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] );
        }
}
 
---------- end of code ---------
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019