Determining the Parent of a Device

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 deletes the devnode for the device from the device tree, and the device becomes a nonpresent device. The approach that you use to determine the parent of a device depends on how the device is currently configured in the system, as follows: