Table of contents
Collapse the table of content
Expand the table of content

Enumerating Installed Devices

Last Updated: 1/24/2017

You should not enumerate devices by using registry keys directly. Registry keys do not contain the required information to enumerate installed devices on the system. This information, such as whether the device is actually present or is a phantom device (one that is not plugged in), is held by the Plug and Play (PnP) manager. The PnP manager also performs additional filtering of registry information.

To enumerate installed devices safely, follow these steps:

  1. Use SetupDiGetClassDevs or SetupDiGetClassDevsEx to retrieve information for a set of devices that belong to a specified device setup class. To retrieve information only for devices that are present in the system, set DIGCF_PRESENT in the Flags parameter.

  2. Use SetupDiEnumDeviceInfo to enumerate the devices in the set.

  3. Use SetupDiGetDeviceInstanceId to retrieve unique device instance identifiers (IDs).

© 2017 Microsoft