DirectX SDK |
The DirectInputCreate function creates a DirectInput object that supports the IDirectInput COM interface.
HRESULT WINAPI DirectInputCreate( HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter );
It is an error for a DLL to pass the handle to 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 to the Web browser. This ensures that DirectInput recognizes the control and can enable any special behaviors that might be necessary.
If the function succeeds, the return value is DI_OK.
If the function fails, the return value can be one of the following error values:
DIERR_BETADIRECTINPUTVERSION |
DIERR_INVALIDPARAM |
DIERR_OLDDIRECTINPUTVERSION |
DIERR_OUTOFMEMORY |
This function has been superseded by DirectInputCreateEx, which can be used to obtain any existing interface to the DirectInput object. It is recommended that you use that function to obtain the IDirectInput7 interface, which has more functionality.
Calling the function with punkOuter = NULL is equivalent to creating the object through CoCreateInstance(&CLSID_DirectInput, punkOuter, CLSCTX_INPROC_SERVER, &IID_IDirectInput, lplpDirectInput), then initializing it with Initialize.
Calling the function with punkOuter != NULL is equivalent to creating the object through CoCreateInstance(&CLSID_DirectInput, punkOuter, CLSCTX_INPROC_SERVER, &IID_IUnknown, lplpDirectInput). The aggregated object must be initialized manually.
There are separate ANSI and Unicode versions of this service. The ANSI version creates an object that supports the IDirectInputA interface, whereas the Unicode version creates an object that supports the IDirectInputW interface. As with other system services that are sensitive to character-set issues, macros in the header file map DirectInputCreate to the appropriate character set variation.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in dinput.h.
Import Library: Use dinput.lib.