SetupDiGetClassDevs介绍

函数SetupDiGetClassDevs返回设备信息集合句柄,包括本地机器的设备信息元素。

函数原型为:

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

Parameters

ClassGuid
A pointer to the GUID for a device setup class or a device interface class. This pointer is optional and can be NULL. For more information about how to set ClassGuid , see the following Comments section.
Enumerator
A pointer to a NULL-terminated string that specifies:
  • An identifier (ID) of a Plug and Play (PnP) enumerator . This ID can either be the value’s globally unique identifier (GUID) or symbolic name. For example, “PCI” can be used to specify the PCI PnP value. Other examples of symbolic names for PnP values include “USB,” “PCMCIA,” and “SCSI”.
  • A PnP device instance ID . When specifying a PnP device instance ID, DIGCF_DEVICEINTERFACE must be set in the Flags parameter.

This pointer is optional and can be NULL. If an enumeration value is not used to select devices, set Enumerator to NULL

For more information about how to set the Enumerator value, see the following Comments section.

hwndParent
A handle of the top-level window to be used for a user interface that is associated with installing a device instance in the device information set. This handle is optional and can be NULL.
Flags
A variable of type DWORD that specifies control options that filter the device information elements that are added to the device information set. This parameter can be a bitwise OR of zero or more of the following flags. For more information about combining these flags, see the following Comments section.
DIGCF_ALLCLASSES
Return a list of installed devices for all device setup classes or all device interface classes.
DIGCF_DEVICEINTERFACE
Return devices that support device interfaces for the specified device interface classes. This flag must be set in the Flags parameter if the Enumerator parameter specifies a device instance ID .
DIGCF_DEFAULT
Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes.
DIGCF_PRESENT
Return only devices that are currently present in a system.
DIGCF_PROFILE
Return only devices that are a part of the current hardware profile.

Return Value

If the operation succeeds, SetupDiGetClassDevs returns a handle to a device information set that contains all installed devices that matched the supplied parameters. If the operation fails, the function returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError .

你可能感兴趣的:(SetupDiGetClassDevs介绍)