Haha, i know .NET is not what you prefer but i found a snippet looking so similar to your desktopscreen copy ( http://www.jose.it-berater.org/smfforum/index.php?topic=2775.msg8263#msg8263 )
It's in dutch but doesn't matter..
http://www.devtips.net/Codeknipsel.aspx?id=697
Could not resist :)
And what about this procedural encapsulation:
hBitmap = GetDesktopScreen() ???
...
And where is this procedure?
Encapsulations based on the low level flat API ;)
GDI32
'// This function return a GDI bitmap.
FUNCTION GetDesktopScreenBitmap() AS LONG
LOCAL hDC, hMemDC, hBitmap AS LONG
' // Get the handle of the desktop device context.
hDC = GetDC(GetDesktopWindow())
' // Create a compatible device context in memory
hMemDC = CreateCompatibleDC(hDC)
' // Create a compatible bitmap using the desktop device context.
hBitmap = CreateCompatibleBitmap(hDC, GetSystemMetrics(%SM_CXSCREEN), GetSystemMetrics(%SM_CYSCREEN))
IF hBitmap THEN
' // Select the compatible bitmap into the memeory device context.
SelectObject(hMemDC, hBitmap)
' // Copy bitmap to the memory device context.
BitBlt(hMemDC, 0, 0, nSize.cx, nSize.cy, hDC, 0, 0, %SRCCOPY)
' // Delete memory device context.
DeleteDC(hMemDC)
' // Release desktop device context.
ReleaseDC(GetDesktopWindow(), hDC)
END IF
FUNCTION = hBitmap
END FUNCTION
GDIPLUS
'// This function return a GDIPLUS image.
FUNCTION GetDesktopScreenImage() AS LONG
LOCAL hBitmap, hImage AS LONG
hBitmap = GetDesktopScreenBitmap()
IF hBitmap THEN
' // Note: GDI+ must have been initialized elsewhere.
IF GdipCreateBitmapFromHBITMAP(hBitmap, BYVAL 0, hImage) = 0 THEN
FUNCTION = hImage
END IF
DeleteObject(hBitmap)
END IF
END FUNCTION
The Dot.NET encapsulation doesn't do anything else, except it put it in a class. ;D
I posted a link above (the first one) already showing this fella.