In PnP's object model, 1 device container object can contain 1...n devnode objects. The way to reference the container object is the container ID property on the devnode. The next question is how to discover the container object. You can't with the old SetupDi APIs. You can with either the Winodws.Devices.Enumeration WinRT API or DevQuery C-style API. Winodws.Devices.Enumeration is built on top of DevQuery.
Here is the sample for Windows.Devices.Enumeration:
The basic idea of the API is you declaratively ask for what you want upfront.
Like: I want
- device container objects.
- based on a selection criteria (eg. its container ID == foo)
- and, I want the following properties off of the object (in the WinRT version, the friendly name is already on the base object)
DevQuery is fundamentally async, but there are both sync and async versions of the query APIs.
BTW, you might as well do the initial devnode enumeration with these APIs as well.
Make sure you are using the DEVPKEY_Device_ContainerId key, and not the base container ID to find the device container object. They are often the same, but not always.