IDirectInput::EnumDevices

The IDirectInput::EnumDevice method enumerates devices that are either currently attached or could be attached to the computer.

HRESULT EnumDevices(
  DWORD dwDevType,              
  LPDIENUMCALLBACK lpCallback,  
  LPVOID pvRef,                 
  DWORD dwFlags                 
);
 

Parameters

dwDevType
Device type filter. If this parameter is zero, all device types are enumerated. Otherwise, it is a DIDEVTYPE_* value (see DIDEVICEINSTANCE), indicating the device type that should be enumerated.
lpCallback
Address of a callback function that will be called with a description of each DirectInput device.
pvRef
An application-defined 32-bit value that will be passed to the enumeration callback each time it is called.
dwFlags
Flag value that specifies the scope of the enumeration. This parameter can be one or more of the following values.
DIEDFL_ALLDEVICES
All installed devices will be enumerated. This is the default behavior.
DIEDFL_ATTACHEDONLY
Only attached and installed devices.
DIEDFL_FORCEFEEDBACK
Only devices that support force feedback

Return Values

If the method succeeds, the return value is DI_OK.

If the method fails, the return value may be one of the following error values:

DIERR_INVALIDPARAM
DIERR_NOTINITIALIZED

Remarks

Keep in mind that all installed devices can be enumerated, even if they are not present. For example, a flight stick may be installed on the system but not currently plugged into the computer. Set the dwFlags parameter to indicate whether only attached or all installed devices should be enumerated. If the DIEDFL_ATTACHEDONLY flag is not present, all installed devices will be enumerated.

A preferred device type can be passed as a dwDevType filter so that only the devices of that type are enumerated.

The lpCallback parameter specifies the address of a callback function of the type documented as DIEnumDevicesProc. DirectInput calls this function for every device that is enumerated. In the callback, the device type and friendly name, and the product GUID and friendly name, are given for each device. If a single input device can function as more than one DirectInput device type, it will be returned for each device type it supports. For example, a keyboard with a built-in mouse will be enumerated as a keyboard and as a mouse. The product GUID would be the same for each device, however.

QuickInfo

  Windows NT: Use version 5.0 or later.
  Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
  Windows CE: Unsupported.
  Header: Declared in dinput.h.
  Import Library: Use dinput.lib.