Board index » delphi » MAC address of the network

MAC address of the network

Hi,

is there a possibility the MAC address of the network map with BCB 5.02
to determine?

Thank you!
J?rg

 

Re:MAC address of the network


Quote
J?rg Otto <j.o...@grainsoft.de> writes:
> is there a possibility the MAC address of the network map with BCB 5.02
> to determine?

[Is it possible to determine the MAC address of a network adapter using
BCB 5.02?]

Depending on which Windows version your program runs on, this might be
helpful http://tinyurl.com/62z5 . This one seems to work for (almost) all
Windows versions: http://tinyurl.com/62zl .

I obtained these (and many others, that might be helpful, too) searching for
"windows sdk mac address" in Google.

Fr gewisse Windows-Versionen k?nnte [der erste Link] hilfreich sein. Der
zweite scheint fr (fast) alle Windows-Versionen zu funktionieren.

Ich habe diese Links (und viele andere, welche auch hilfreich sein k?nnten)
mit Google gefunden, indem ich nach "windows sdk mac address" gesucht habe.

Re:MAC address of the network


with this function i obtain the mac address of my computer:

#include <stdlib.h>
#include <stdio.h>
#include <Nb30.h>

void __fastcall ReturnMac(void)
{
    DWORD nSize;
    nSize = 30;
    String str;

    //lettura dell'user loginato
    GetUserName(InfoComputer.UserComputer,&nSize);

    //lettura del nome computer
    GetComputerName(InfoComputer.NameComputer,&nSize);

    E_User->Text = String(InfoComputer.UserComputer);
    E_Computer->Text = String(InfoComputer.NameComputer);

    //lettura dell'indirizzo MAC
    NCB Ncb;
    UCHAR uRetCode;
    LANA_ENUM lenum;
    ASTAT Adapter;

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

    for (int 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);

        memset(&Ncb,0,sizeof(Ncb));
        Ncb.ncb_command = NCBASTAT;
        Ncb.ncb_lana_num = lenum.lana[i];

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

        uRetCode = Netbios(&Ncb);

        if ( uRetCode == 0 )
        {
   InfoComputer.m_strClientMacAddr0 = Adapter.adapt.adapter_address[0];
   InfoComputer.m_strClientMacAddr1 = Adapter.adapt.adapter_address[1];
   InfoComputer.m_strClientMacAddr2 = Adapter.adapt.adapter_address[2];
   InfoComputer.m_strClientMacAddr3 = Adapter.adapt.adapter_address[3];
   InfoComputer.m_strClientMacAddr4 = Adapter.adapt.adapter_address[4];
   InfoComputer.m_strClientMacAddr5 = Adapter.adapt.adapter_address[5];

   str.sprintf( "%02X-%02X-%02X-%02X-%02X-%02X",
      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] );
        }
    }

    E_MacAddress->Text = str;

Quote
}

typedef struct _InfoComputer_
{
    unsigned char m_strClientMacAddr0;
 unsigned char m_strClientMacAddr1;
 unsigned char m_strClientMacAddr2;
 unsigned char m_strClientMacAddr3;
 unsigned char m_strClientMacAddr4;
 unsigned char   m_strClientMacAddr5;

    char UserComputer[20];
    char NameComputer[20];

    String IPNoritsu;

Quote
} TInfoComputer;

test it!!!

hi, Carruba74

"J?rg Otto" <j.o...@grainsoft.de> ha scritto nel messaggio
news:3E539608.C4E481AB@grainsoft.de...

Quote
> Hi,

> is there a possibility the MAC address of the network map with BCB 5.02
> to determine?

> Thank you!
> J?rg

Other Threads