Reputation: 31
NetworkInterface.GetAllNetworkInterfaces() doesn't return a complete list, when I go to A network device, and using properties I disable internet protocol version 4(TCP/IPv4) check box, GetAllNetworkInterfaces stop recognizing the device. I find this odd as although the device is not internet capable after this(we still may have IPv6 but for the sake of the argument) its still a network device can someone explain this, or show how this can be solved?
Upvotes: 0
Views: 979
Reputation: 31
After some time searching I found that a complete list can be accessed by using the following:
SelectQuery wmiQuery = new SelectQuery("SELECT * FROM Win32_NetworkAdapter");
ManagementObjectSearcher searchProcedure = new ManagementObjectSearcher(wmiQuery);
foreach (ManagementObject networkAdapter in searchProcedure.Get())
{
//here do whatever you want to do to the adapter
}
A more general description can be found at(not C# specific): http://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx
Also in C# make sure to reference System.Management, or you wan't be able to use the code above
Upvotes: 1