See GetAdaptersInfo function for the details.
This sample program makes some basic use of the API call and the results it returns to report on network adapters in your system. If you need more information you can easily expand upon it to extract multiple IP addresses where they exist, etc.
There are some limitations when using early versions of Windows, so see the MSDN link above if you need support for Windows XP or earlier.
Sample output, Adapter 0 is not connected to a network:
This works even when WMI is not installed, the WMI Service is stopped, or WMI has "gone bye bye" and started returning bogus results.
Note that Address varies by adapter type. For Ethernet, WiFi, and similar network media adapters this is the MAC Address.
This might look like a lot of code, but much of it consists of structure definitions (UDTs). For specific purposes you can trim out things you do not need which can reduce it further.
This sample program makes some basic use of the API call and the results it returns to report on network adapters in your system. If you need more information you can easily expand upon it to extract multiple IP addresses where they exist, etc.
There are some limitations when using early versions of Windows, so see the MSDN link above if you need support for Windows XP or earlier.
Sample output, Adapter 0 is not connected to a network:
Code:
2 adapter(s) found.
Adapter 0:
Description = Realtek RTL8191SU Wireless LAN 802.11n USB 2.0 Network Adapter
AdapterIndex = 23
Name = {E9D4C1E7-8714-4545-A74B-A2FF60453A00}
Type = 71
Address = 00-12-71-BA-C4-34
IP = 0.0.0.0
GatewayIP = 0.0.0.0
Adapter 1:
Description = Realtek PCIe GBE Family Controller
AdapterIndex = 11
Name = {F4747718-7BF6-4369-97C0-76A31249F698}
Type = 6
Address = 00-14-71-21-A3-11
IP = 192.168.0.100
GatewayIP = 192.168.0.1
Note that Address varies by adapter type. For Ethernet, WiFi, and similar network media adapters this is the MAC Address.
This might look like a lot of code, but much of it consists of structure definitions (UDTs). For specific purposes you can trim out things you do not need which can reduce it further.