DirectX SDK |
The information in this topic pertains only to applications written in C++.
You can create a DirectDraw object by using the CoCreateInstance function and the IDirectDraw7::Initialize method rather than the DirectDrawCreate function. The following steps describe how to create the DirectDraw object:
if (FAILED(CoInitialize(NULL))) return FALSE;
ddrval = CoCreateInstance(&CLSID_DirectDraw, NULL, CLSCTX_ALL, &IID_IDirectDraw7, &lpdd); if(!FAILED(ddrval)) ddrval = IDirectDraw7_Initialize(lpdd, NULL);
In this call to CoCreateInstance, the first parameter, CLSID_DirectDraw, is the class identifier of the DirectDraw driver object class, the IID_IDirectDraw7 parameter identifies the particular DirectDraw interface to be created, and the lpdd parameter points to the DirectDraw object that is retrieved. If the call is successful, this function returns an uninitialized object.
Before you close the application, close the COM library by using the CoUninitialize function.
CoUninitialize();