Ca donnerait qq chose comme ça (aux étourderies près) :
void CaptureScreen(HWND hWndMain, long Left, long Top, long Width, long Height)
{
HDC srcDC;
HDC trgDC;
HBITMAP BMPHandle;
DEVMODE *dm;
srcDC = CreateDC("DISPLAY", "", "", &dm);
trgDC = CreateCompatibleDC(srcDC);
BMPHandle = CreateCompatibleBitmap(srcDC, Width, Height);
SelectObject(trgDC, BMPHandle);
BitBlt(trgDC, 0, 0, Width, Height, srcDC, Left, Top, SRCCOPY);
OpenClipboard(hWndMain);
EmptyClipboard();
SetClipboardData(CF_BITMAP, BMPHandle);
CloseClipboard();
DeleteDC(trgDC);
ReleaseDC(BMPHandle, srcDC);
}
Les dimensions de la fenêtre principale, on peut les avoir avec GetWindowRect()
Le hWnd "main" se retrouve par hWndMain = GetDesktopWindow();