IDirect3D9::CreateDevice

CreateDevice is a member of IDirect3D9. It creates a device to represent the display adapter. This function must be called durring the handling of WM_CREATE.

Syntax
HRESULT CreateDevice( UINT Adapter,  D3DDEVTYPE DeviceType,  HWND hFocusWindow,  DWORD BehaviorFlags,  D3DPRESENT_PARAMETERS * pPresentationParameters,  IDirect3DDevice9 ** ppReturnedDeviceInterface );

Parameters
Adapter - Ordinal number that represents the display adapter, most likely D3DADAPTER_DEFAULT.

DeviceType - Represents the desired device type. See D3DDEVTYPE. hFocusWindow - This is the focus window that tells the device when the focus changes.
 * Fullscreen - Must be a Top-Level window.
 * Windowed - May be NULL if the window parameter of pPresentationParameters is set to a valid, non-NULL value.

BehaviorFlags - One or more flags that control device creation. See D3DCREATE.

pPresentationParamaters - A pointer to the D3DPRESENT_PARAMETERS structure. It must contain the following data: ppReturnedDeviceInterface - Address to the pointer to the device that will be created. It is the type IDirect3DDevice9.
 * Refresh Rate
 * BackBufferCount
 * BackBufferWidth
 * BackBufferHeight
 * BackBufferFormat

Returned Values
If it worked, it will return D3D_OK, otherwise, it will return one of the following: D3DERR_DEVICELOST, D3DERR_INVALIDCALL, D3DERR_NOTAVAILABLE, D3DERR_OUTOFVIDEOMEMORY.

Requirements
Header: d3d9.h

Library: d3d9.lib