I need to determine the MAC address of the network adapter that is currently in use.
On my PC (where I test my code) multiple network adapters seem to be active. One from the network adapter that is connected to the LAN (that's the one I would be interested in), and 2 virtual network adapters registered by VMWare. And when - for test purposes - I connect my iPhone I get one more adapter.
Unfortunately a lot of "solutions" I found list the MAC addresses in some random order, so the active one might be at any place in the list.
I tried various methods, e.g.
- via Netbios (NB30.pas) - list adapters in no particular order
- via JCL (GetMacAddresses from jclsysinfo.pas) - also no particular order
- Original source from GetAdaptersInfo not working on Delphi XE6 - failed to compile
- http://www.delphipraxis.net/110213-den-namen-der-netzwerkverbindung-ermitteln-w2k.html - fails with range check error
- Cody by Remy L from GetAdaptersInfo not working on Delphi XE6 - fails to compile
Can anybody give my a hint which way to look? I am using Delphi2010, this might be a problem for the post related to XE6.
Edit: It turns out there is no such thing as a single active network adapter. So there will not be a proper answer for this question and - in my view - this issue can be closed. I tried to make that by writing an answer, but that seems to violate so-policies and the post was deleted. Anyway, thanks for your help.