CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Posts
    60

    MAC Address when NOT connected to network

    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).

  2. #2
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    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";

  3. #3
    Join Date
    Aug 2002
    Location
    VA, USA
    Posts
    137
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured