Mail Archives: djgpp/2002/08/31/11:15:08
"Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk> wrote in message news:3D706C40 DOT 1C7B6085 AT phekda DOT freeserve DOT co DOT uk...
> Hello.
>
> Alex Vinokur wrote:
> > Is it possible to get MAC address within C/C++-program ?
>
> On which operating system?
Windows 2000
DJGPP 2.03
> There is no method that will work on DOS and all
> versions of Windows.
>
> You can use RegDos to read the registry on Windows '95, '98 and ME. Then you
> can obtain the MAC address. See:
>
> http://www.phekda.freeserve.co.uk/richdawe/dl/winnetip.htm
Here is a fragment of that file :
====== BEGIN ======
Windows 2000
This info was supplied by Noël Danjou - thanks.
Network Cards
Like Windows NT, Windows 2000 stores its configuration data in the registry. A list of network cards is stored under this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards
Each network card has a subkey with values. The "Description" value contains a human-friendly description. The "ServiceName" value
contains a GUID (globally-unique identifier?) (cf. Windows NT, which has a name here).
The IP data for the network card is then found off this key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
Each network has a key of the form "{GUID}", e.g. "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", where each "x" represents a hexidecimal
digit. Each of the GUID keys has values for lease times, subnet masks and IP addresses. For IP addresses there are two possible
values:
a.. "IpAddress" of type REG_MULTI_SZ (multiple nul-terminated strings), which contains all the static IP addresses or "0.0.0.0" if
there are none;
b.. "DhcpIpAddress" (optional) of type REG_SZ (nul-terminated string), which contains the dynamic IP address.
====== END ========
From where can I get MAC Address within my C/C++ program ?
>
> There are other methods, but they are for Windows programs. The Winsock
> Programmer's FAQ details how.
>
> You could write a small helper Windows program to return the MAC address.
The same question : From where can I get MAC Address within my C/C++ program ?
>Then your program would run the helper program, to get the MAC address.
>
> HTH, bye,
>
> --
> Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
Thanks,
==================
Alex Vinokur
mailto:alexvn AT go DOT to
http://up.to/alexvn
==================
- Raw text -