Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Listing 111 setup classes.
XboxComposite : Xbox Peripherals
RemotePosDevice : POS Remote Device
DigitalMediaDevices : Digital Media Devices
PrintQueue : Print queues
So from that I can see there are 111 setup classes. However, when I query for
Win32_PnPEntity
:
var query = new ManagementObjectSearcher("SELECT * FROM Win32_PnPEntity");
var results = query.Get();
var set = new HashSet<string>();
foreach(var device in results)
var className = (string)device.GetPropertyValue("PNPClass");
set.Add(className)
var count = set.Count; // 25 <---- not 111
I get 25, not 111. So My query is clearly a subset of what's actually available to the machine which makes sense. The classes that output from devcon classes
line up with the PNPClass
property value, so I assume they are the same.
So there must be a way to fetch all the available PNPClass
's unless devcon.exe
just hardcodes that list it outputs with devcon classes
I would like to generate this list myself programmatically, not invoking devcon classes
as a subprocess and parsing it's output.
Unfortunately, Win32_PNPEntity doesn't map exactly to the data you would get from devcon. Devcon gives you all the available classes on the system including System, filter, PNP, etc. Win32_PNPEntity is just the plug and play devices. Win32_PNPEntity data also depends on what hardware is currently connected.
devcon is outputting all the data from the subkeys in "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class" where there is no name/value called NoUseClass=1. It's displaying the Class and ClassDesc values. The ClassDesc value could be either a literal string, a reference to a value in a .inf or a reference from a dll so outputting that info would take some work.
What are you trying to do with that data? Maybe there is another way you can get the info you need? If you are just trying to get the class info for connected PNP devices then your existing code should get the info you need.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.