The sequence of Windows API calls is as follows:
HDC sourceDC =
CreateDC( L"DISPLAY", // lpszDriver - driver name
NULL, // lpszDevice -
device name
NULL, // lpszOutput - not
used; should be NULL
NULL );
HDC memoryDC =
CreateCompatibleDC( sourceDC );
HBITMAP bitmap =
CreateCompatibleBitmap( sourceDC, //
hdc - handle to DC
horizontalResolution, // nWidth - width of bitmap, in pixels
verticalResolution );
SelectObject( memoryDC, // hdc - handle to DC
bitmap );
StretchBlt( memoryDC, //
hdcDest - handle to destination DC
0, // nXOriginDest - x-coord of
destination upper-left corner
0, // nYOriginDest - y-coord of
destination upper-left corner
horizontalResolution, //
nWidthDest - width of destination rectangle
verticalResolution, //
nHeightDest - height of destination rectangle
sourceDC, //
hdcSrc - handle to source DC
0, // nXOriginSrc - x-coord of
source upper-left corner
0, // nYOriginSrc - y-coord of
source upper-left corner
sourceHorizonalResolution, //
nWidthSrc - width of source rectangle
sourceVerticalResolution, //
nHeightSrc - height of source rectangle
SRCCOPY );
(Note: For clarity, I have omitted error checking code from the above
excerpt. I am evaluating and handling the return value of every
function.).
All operations up until the StretchBlt function succeed.
Anyone know of any reason why this would fail when run under the
system account? I have reproduced this on several systems including XP
Pro and Vista.
Thanks for your help.