Click to See Complete Forum and Search --> : MAC Address when NOT connected to network


penina
March 2nd, 2003, 11:43 AM
Hello,

Is there a way to read the MAC address when the computer is
not connected to the network?

All three ways in:
http://www.codeguru.com/network/GetMAC.html
Do not work when the computer is not connected to the network.
(You have to disconnect the computer and restart it).

Mick
March 2nd, 2003, 01:50 PM
Interesting...GetAdaptorsInfo is suppose to work even if your not connected to the Network but the adaptors have to be enabled, as the comment in the link suggests. Never had the need to get a adapter status when the network isn't connected, but there is a fourth way using WMI...Win32_NetworkAdapterConfiguration

queryclass = L"select * from Win32_NetworkAdapterConfiguration";

querystring = L"MacAddress";

willchop
March 3rd, 2003, 11:47 AM
penina,

I've used services of the iphlpapi.dll to get MACs while network
is unplugged. Basically, you get the address of the "GetIfTable"
function from the dll. Make an inital call to the function to get
the amount of memory you need to hold the result interface
table. Then call the function agian to get the actual interface
table data. Once you have the data, you iterate through the
table until you find an interface that resembles a network
adapter (see ipifcons.h MIB_IF_TYPE*). Then just grab the
physical address field from the data and your done.

regards, willchop