Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Sometimes it is necessary to access the parent of a device. For example, the operation of some types of hardware devices depends on a fixed relationship between a specific parent and set of child devices. To uninstall such a hardware device, you must uninstall the parent in addition to all the child devices. To uninstall the parent, you must obtain a SP_DEVINFO_DATA structure for the parent. A Universal Serial Bus (USB) composite device, such as, a multifunction printer, is such a device. It is represented in the system by a parent composite device and one or more child interface devices (see USB Driver Stack Architecture). To uninstall a multifunction printer, you must uninstall its parent composite device in addition to all its child interface devices.
When the Plug and Play (PnP) manager configures a device in the system, it adds a device node (devnode) for the device to the device tree. When the PnP manager removes a device from the system, it removes the devnode for the device from the device tree, and the device becomes a non-present device.
To determine the device instance ID of the parent of a device, you can query the DEVPKEY_Device_Parent property on the device using SetupDiGetDeviceProperty. For a present device, this will provide you the device instance ID of the parent of that device. For a non-present device:
- On Windows 8 and later:
- If the parent of the non-present device from the last time the non-present device was a present device still exists as a device on the system (present or non-present device), DEVPKEY_Device_Parent will provide the device instance ID of that parent device.
- If the parent of the non-present device from the last time the non-present device was a present device does not still exist as a device on the system, DEVPKEY_Device_Parent will return the device instance ID of the device that is at the root of the device tree.
- Prior to Windows 8:
- Retrieving DEVPKEY_Device_Parent will return an error that the property is not found.
Once you have the device instance ID of the parent device, you can use SetupDiOpenDeviceInfo to obtain a SP_DEVINFO_DATA structure for the parent.