Getting devices on .NET without using WMI
-
15-06-2021 - |
Question
How can I get a device group or the network devices that shows the Device Manager window without WMI? I tried with devcon but returns all nics.
For example, devcon returns:
and I just want these one (without the show hidden devices option)
Any kind of solution for devcon or net framework 2, idea or workaround will be treated as solution if its works.
Solution
To list the network adapters you can use the GetAdaptersInfo
WinAPi function, since you are using .Net try the PInvoke page for a sample.
OTHER TIPS
Try System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(). It returns a collection of all detected network interfaces. You can then filter it down to the interfaces whose operational status is "Up", and/or that have valid IP interface properties (such as a defined IPv4/IPv6 address)