IDirectInputDevice::Initialize

The IDirectInputDevice::Initialize method initializes a DirectInputDevice object. The IDirectInput::CreateDevice method automatically initializes a device after creating it; applications normally do not need to call this method.

HRESULT Initialize(
  HINSTANCE hinst,  
  DWORD dwVersion,  
  REFGUID rguid     
);
 

Parameters

hinst
Instance handle to the application or DLL that is creating the DirectInput device object. DirectInput uses this value to determine whether the application or DLL has been certified and to establish any special behaviors that may be necessary for backwards compatibility.

It is an error for a DLL to pass the handle of the parent application. For example, an ActiveX control embedded in a Web page that uses DirectInput must pass its own instance handle and not the handle of the web browser. This ensures that DirectInput recognizes the control and can enable any special behaviors that may be necessary.

dwVersion
Version number of DirectInput for which the application is designed. This value will normally be DIRECTINPUT_VERSION. Passing the version number of a previous version will cause DirectInput to emulate that version. For more information, see Designing for Previous Versions of DirectInput.
rguid
Identifier for the instance of the device for which the interface should be associated. The IDirectInput::EnumDevices method can be used to determine which instance GUIDs are supported by the system.

Return Values

If the method succeeds, the return value is DI_OK or S_FALSE.

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

DIERR_ACQUIRED
DIERR_DEVICENOTREG

If the method returns S_FALSE, the device had already been initialized with the instance GUID passed in though rGUID.

Remarks

If this method fails, the underlying object should be considered to be in an indeterminate state and must be reinitialized before use.

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.