Board index » delphi » About the MAC address of ethernet cards

About the MAC address of ethernet cards

Do any of you know how to get the MAC address of an ethernet card?

I'm developing a network app that needs to identify machines of a
network, not relying on their network name nor IP address.
Currently I'm using NetBIOS calls to get the MAC, but it seems that
sometimes (in some user sessions) the Netbios function returns junk in
the Netbios_AdapterStatus record.

This message can be considered as a warning for any of you using this
call: I think that the 30 names table is not enough big to hold the
response,
even when you set accordingly the ncb.bufferLength field.
I have converted the Win32.hlp's example 'Getting the MAC address for
an Ethernet Adapter' to Delphi 2, if you are interested.

Also, another warning:  before using NetBIOS, I used the registry,
getting the MAC from the 'NetworkAddress' key.  Do not rely on its contents,
as system administrators may use the 'Ghost' utility to backup entire
harddrives, or even change the network card without Windows 95 noticing.
In both cases, the registry key is not updated.

I'm also interested in the use of the NetSessionEnum call.  I'm having
trouble trying to obtain a list of all the sessions opened by the users of
the network.  I only need to know which user is using what computer. Please
give me advise about this, or if you know where can I find more information.

Thank you for your interest.

----------------
Manuel Gonzalez.
BRiNDYS Software.
http://www.eui.upv.es/brindys/default.htm

 

Re:About the MAC address of ethernet cards


Manuel Gonzalez 'BRiNDYS' <brin...@lettera.skios.es> wrote:

Quote
> Do any of you know how to get the MAC address of an ethernet card?

I'm also still searching for some working code, however I know at least in
principle another way except those you already tried.

Quote
> Also, another warning:  before using NetBIOS, I used the registry,
> getting the MAC from the 'NetworkAddress' key.  Do not rely on its contents,
> as system administrators may use the 'Ghost' utility to backup entire
> harddrives, or even change the network card without Windows 95 noticing.

And on NT 4 there's one such key, but it doesn't contain the MAC but any
other data (it's in the Software\Microsoft\Rpc\UuidTemporaryData, don't
think it has anything to do with a network card there).

I suggest to take a look at SNMP instead. If there's a real SNMP running on
the machine you can just request the MIB for the MAC, however as this won't
be the case on most systems there are some few pseudo SNMP DLL which the arp
and netstat command make use of. MS has choosen not to document them, and of
course the '95 and NT version aren't compatible. Take a look at
http://users.lia.net/chris/snmp.html, there you can find a little bit of
information about this - I still have to translate the C++ files there to
Delphi and test it myself...

Hope this helps,
   Andy

---
Andreas H"orstemeier                       | ..Our continuing mission:
email: a...@scp.de                         | to seek out knowledge of C,
       a...@hoerstemeier.de                | to explore strange unix
www:   http://www.westend.de/~hoerstemeier | commands, and to boldly code
fido:  2:2452/108     ICQ: 1661968         | where no one has man page 4.

Other Threads