I have a function which captures part of the screen and places it into a memory DC using DirectDraw7. I have very specific reasons why I need to use DirectDraw versus GDI to capture the screen and explaining them is irrelevant.
The DirectDraw7 algorithm is very straightforward and works great:
surfDescPrimary.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE
lpDDrawObject7->CreateSurface( &surfDescPrimary, &lpSurfacePrimary, NULL );
surfDescBBuffer.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
lpDDrawObject7->CreateSurface( &surfDescBBuffer, &lpSurfaceBackBuffer, NULL );
hr = lpSurfaceBackBuffer->GetDC(&hBSurfDC);
The problem is that I need to support multiple monitors and the latest OSes (from Win2k to Win7). I tried to use the DirectDrawEnumerateEx api to query the monitor's GUID but this function returns DDERR_UNSUPPORTED (as well as DirectDrawEnumerate).
I know that DirectDraw has been deprecated and transferred over to Direct3D9. So I assume that on Vista (for instance), DirectDrawCreateEx,CreateSurface and BltFast are supported, but not DirectDrawEnumerateEx.
This only gives me half of a solution to capture the screen efficiently.
I am looking for alternative to either:
A. Query the GUIDs of monitors attached to the desktop so that I can use them in DirectDrawCreateEx.
B. A similar algorithm through D3D9 to capture the screen efficiently (avoiding the GetFrontBufferData API which is slow by design).
Any expert suggestion?