🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1005

Re: how to get netcard mac address

#1005
From: zhoufanenator
Date: Wed, 31 Oct 2007 03:09
67 lines
3021 bytes
On Oct 31, 1:59 pm, zhoufanena...@gmail.com wrote:
> On Sep 30, 1:33 am, "zhan wei ming" <zhanweim...@hotmail.com> wrote:
>
> > Hi,
> > Can anybody tell me how to get netcard mac address?
>
> > Thanks,
> > Zhan
>
> 'getmac' in dos

Or in bcb

Sample Code
-----------

   #include <windows.h>
   #include <wincon.h>
   #include <stdlib.h>
   #include <stdio.h>
   #include <time.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];

      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] );
      }
   }
Technical Details
Message-ID: <1193800169.732669.51260@v29g2000prd.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!v29g2000prd.googlegroups.com!not-for-mail
References: <46fe6444@newsgroups.borland.com> <1193799586.401466.27690@v29g2000prd.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4a7fdb078d856a0a
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!v29g2000prd.googlegroups.com!not-for-mail
From:  zhoufanenator@gmail.com
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: how to get netcard mac address
Date: Wed, 31 Oct 2007 03:09:29 -0000
Organization: http://groups.google.com
Lines: 68
Message-ID: <1193800169.732669.51260@v29g2000prd.googlegroups.com>
References: <46fe6444@newsgroups.borland.com>
   <1193799586.401466.27690@v29g2000prd.googlegroups.com>
NNTP-Posting-Host: 202.12.144.21
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1193800170 29469 127.0.0.1 (31 Oct 2007 03:09:30 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 31 Oct 2007 03:09:30 +0000 (UTC)
In-Reply-To: <1193799586.401466.27690@v29g2000prd.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.0 ncai (NetCache NetApp/5.6.2R1D28), 1.1 ncao (NetCache NetApp/5.6.2R1D28)
Complaints-To: groups-abuse@google.com
Injection-Info: v29g2000prd.googlegroups.com; posting-host=202.12.144.21;
   posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0