Previous Next

SetupDiGetClassDevs

The SetupDiGetClassDevs function returns a device information set that contains all devices of a specified class.

HDEVINFO
  SetupDiGetClassDevs(
    IN LPGUID  ClassGuid,  OPTIONAL
    IN PCTSTR  Enumerator,  OPTIONAL
    IN HWND  hwndParent,  OPTIONAL
    IN DWORD  Flags
    );

Parameters

ClassGuid
Optionally points to a class GUID for a setup class or an interface class. If the DIGCF_DEVICEINTERFACE flag is set, ClassGuid represents an interface class; otherwise, ClassGuid represents a setup class.

If the DIGCF_ALLCLASSES flag is set, this parameter is ignored and the resulting list contains devices of all installed classes.

Enumerator
Optionally points to a string that filters the devices that are returned.

If the DIGCF_DEVICEINTERFACE flag is set, this parameter optionally points to a string representing the PnP name of a particular device. This function only examines this particular device to determine whether it exposes any interfaces of the requested interface class.

If the DIGCF_DEVICEINTERFACE flag is not set, this parameter optionally specifies the name of the PnP enumerator that enumerates the devices of interest. (The names of system-supplied enumerators appear in register.h.) This function only examines device instances of this enumerator. If this parameter is NULL, this function retrieves device information for all device instances on the system.

hwndParent
Supplies the handle of the top-level window to be used for any user interface relating to the members of this set.
Flags
Supplies control options used in building the device information set. Can be a combination of the following values:
DIGCF_ALLCLASSES
Return a list of installed devices for all classes. If this flag is set, the ClassGuid parameter is ignored.
DIGCF_DEVICEINTERFACE
Return devices that expose interfaces of the interface class specified by ClassGuid. If this flag is not set, ClassGuid specifies a setup class.
DIGCF_PRESENT
Return only devices that are currently present.
DIGCF_PROFILE
Return only devices that are a part of the current hardware profile.

Return Value

SetupDiGetClassDevs returns a handle to a device information set containing all installed devices matching the specified parameters. If the function fails, it returns INVALID_HANDLE_VALUE or another appropriate error. To get extended error information, call GetLastError.

Headers

Declared in setupapi.h. Include setupapi.h.

Comments

The caller of this function must delete the returned device information set when it is no longer needed by calling SetupDiDestroyDeviceInfoList.

If DIGCF_DEVICEINTERFACE is set, ClassGuid (if used) must point to a device interface class GUID and Enumerator (if used) must point to a PnP device name. The returned device information set contains devices that expose interfaces of the requested interface class. Enumerate the interfaces of the devices using SetupDiEnumDeviceInterfaces.

If DIGCF_DEVICEINTERFACE is not set, ClassGuid (if used) must point to a setup class GUID and Enumerator (if used) must specify the name of the PnP enumerator that enumerates the devices of interest.

Call SetupDiGetClassDevsEx to retrieve the devices for a class on a remote machine.

See Also

SetupDiCreateDeviceInfoList, SetupDiDestroyDeviceInfoList, SetupDiEnumDeviceInterfaces, SetupDiGetClassDevsEx