Edit

Share via


Opening software keys for all devices in a setup class

When a user-mode application opens the software keys for all devices in a device setup class, it must not directly access the registry to enumerate the subkeys of a device setup class. As with any registry key, the location and name of this key might change between different versions of Windows.

To safely enumerate and open the subkeys of a device setup class, follow these steps:

Note

Some devices might not have software keys, such as when a device is present and enumerated by the Plug and Play (PnP) manager but has not been installed.

Using configuration manager functions:

  1. Use CM_Get_Device_ID_List with a ulFlags of CM_GETIDLIST_FILTER_CLASS and a pszFilter with the GUID of the desired device setup class to retrieve a list of device instance paths for all devices in the specified device setup class.

  2. For each returned device instance path, use CM_Locate_DevNode to retrieve a DEVINST representing the device.

  3. Use CM_Open_DevNode_Key with ulFlags containing CM_REGISTRY_SOFTWARE to open the software key for each device. See Opening a device's software key for more information.

Using SetupApi functions:

  1. Use SetupDiGetClassDevs or SetupDiGetClassDevsEx to retrieve a set of information about all devices for a specified device setup class.

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

  3. Use SetupDiOpenDevRegKey to open the software key for each device. The KeyType parameter must be set to DIREG_DRV.