?/TD> |
Microsoft DirectX 9.0 |
Creates and initializes an instance of a device based on a given globally unique identifier (GUID), and obtains an IDirectInputDevice8 interface.
Syntax
HRESULT CreateDevice(
REFGUID rguid, LPDIRECTINPUTDEVICE *lplpDirectInputDevice, LPUNKNOWN pUnkOuter );
Parameters
- rguid
- Reference to (C++) or address of (C) the instance GUID for the desired input device (see Remarks). The GUID is retrieved through the IDirectInput8::EnumDevices method, or it can be one of the predefined GUIDs listed below. For the following GUID values to be valid, your application must define INITGUID before all other preprocessor directives at the beginning of the source file, or link to Dxguid.lib.
- GUID_SysKeyboard
- The default system keyboard.
- GUID_SysMouse
- The default system mouse.
- lplpDirectInputDevice
- Address of a variable to receive the IDirectInputDevice8 interface pointer if successful.
- pUnkOuter
- Address of the controlling object's IUnknown interface for Component Object Model (COM) aggregation, or NULL if the interface is not aggregated. Most callers pass NULL.
Return Value
If the method succeeds, the return value is DI_OK.
If the method fails, the return value can be one of the following:
DIERR_DEVICENOTREG The device or device instance is not registered with Microsoft?DirectInput? This value is equal to the REGDB_E_CLASSNOTREG standard COM return value. DIERR_INVALIDPARAM An invalid parameter was passed to the returning function, or the object was not in a state that permitted the function to be called. This value is equal to the E_INVALIDARG standard COM return value. DIERR_NOINTERFACE The specified interface is not supported by the object. This value is equal to the E_NOINTERFACE standard COM return value. DIERR_NOTINITIALIZED The object has not been initialized. DIERR_OUTOFMEMORY The DirectInput subsystem couldn't allocate sufficient memory to complete the call. This value is equal to the E_OUTOFMEMORY standard COM return value.
Remarks
Calling this method with pUnkOuter = NULL is equivalent to creating the object by CoCreateInstance (&CLSID_DirectInputDevice, NULL, CLSCTX_INPROC_SERVER, riid, lplpDirectInputDevice) and then initializing it with Initialize.
Calling this method with pUnkOuter != NULL is equivalent to creating the object by CoCreateInstance (&CLSID_DirectInputDevice, punkOuter, CLSCTX_INPROC_SERVER, &IID_IUnknown, lplpDirectInputDevice). The aggregated object must be initialized manually.