Enumerating Installed Devices

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).

 

 

Send comments about this topic to Microsoft

표시:
© 2014 Microsoft