Detailed function SetupDiGetClassDevs

SetupDiGetClassDevs function

SetupDiGetClassDevs  function returns the requested information to all devices on the machine comprises a device information sets handle.

grammar

//C++:
HDEVINFO SetupDiGetClassDevs(
  _In_opt_ const GUID   *ClassGuid,
  _In_opt_       PCTSTR Enumerator,
  _In_opt_       HWND   hwndParent,
  _In_           DWORD  Flags
);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

parameter

ClassGuid [input parameters, optional] 
a pointer pointing to the GUID, the GUID identifies a device class or a mounting device interface class. This pointer is optional, and may be NULL . More about ClassGuid assignment questions, please refer to the notes section.

The Enumerator [input parameters, optional] 
a pointer to a null-terminated string specifying:

  • Plug and Play ID for the device enumeration tree, this ID may be a globally unique identifier (GUID) may be a symbolic name. For example: " PCI " PnP may be used to specify the value of PCI, the symbolic name of the image including "the USB", " the PCMCIA " and "SCSI" such Pnp value.

  • A PnP device handle ID. When specifying a device handle PnP ID, DIGCF_DEVICEINTERFACE must be provided on the Flag parameter.

The hwndParent [input parameters, optional] 
top-level window handle for instance associated with the device installed in the device information focused on a user interface. The handle is optional and can be NULL.

The Flags [input parameter] 
the Flags DWORD is a type of variable focus device information filtered by the apparatus specified by this parameter. This parameter may be a bit or a combination of, the following additional information flag of one or more of the relevant flags in combination, refer to the comments section.

DIGCF_ALLCLASSES 
  return a list of all installed devices or all devices interface class.

DIGCF_DEVICEINTERFACE 
  Device specified device interface class support. If Enumerators argument developed the device instance ID, you must set this flag in the Flags parameter.

DIGCF_DEFAULT 
  for the specified device interface class, only to return the device interface device associated with the system default (if provided).

DIGCF_PRESENT 
  only returns the current (connected) devices present in the system.

DIGCF_PROFILE 
  return only part of the current hardware equipment list.

return value

If the call succeeds, SetupDiGetClassDevs returns a device information set handle, which contains all the equipment and provided the parameters match. If the call fails, the function returns INVALID_HANDLE_VALUE . To get further error information, call GetLastError .

Remark

After calling this function when processed and the corresponding data, you must call SetupDiDestroyDeviceInfoList function.

Call SetupDiGetClassDevsEx to retrieve the device on the remote computer.

Equipment installation class control options 
using the following filter options to control SetupDiGetClassDevs whether to return all the equipment:

  • To return all devices, set flags DIGCF_ALLCLASSES, and ClassGuid set to NULL.
  • If only returns the specified device, do not move DIGCF_ALLCLASSES flag, but should use Guid CLassGuid provided.

Additionally, the following combination can also be further controlled condition of the filter device:

  • DIGCF_PRESENT flag provided to return the system currently connected devices.
  • DIGCF_PROFILE flag is set to return to the current hardware configuration file in the list of devices.
  • To return a PnP device enumeration, use Enumerator parameters and provide its GUID or symbolic name. If Enumerator is NULL, SetupDiGetClassDevs return all PnP device enumeration.

Device interface class control options 
using the following filter options to control SetupDiGetClassDevs whether to return to support any type of equipment or device interface returns only support the specified device interface class equipment:

  • To return to support any kind of device interfaces, set both DIGCF_DEVICEINTERFACE and DIGCF_ALLCLASSES flags and ClassGuid set to NULL . The function of the device showing the device information setting apparatus of this information element, and then add the device interface comprising a list of all devices supported by the device interfaces to a device information element.

Guess you like

Origin blog.csdn.net/thanklife/article/details/88025371