Black screenshots using c++ and cygwin sshd service
I have a problem when trying to capture screenshots using c++ on windows xp.
The code is similar to this:
hDc = CreateCompatibleDC(0);
hBmp = CreateCompatibleBitmap(GetDC(0), width, height);
HGDIOBJ obj = SelectObject(hDc, hBmp);
BitBlt(hDc, 0, 0, width, height, GetDC(0), 0, 0, SRCCOPY);
It runs fine on the machine normally, but when I login wit开发者_C百科h ssh to the cygwin shell I just get a black screenshot running the same code. BitBlt
returns 0 and GetLastError
returns 6 which indicates an invalid handle. But none of the handles are 0. So how could I make this work, I am a bit lost as to what exactly the problem is.
When you log into Cygwin over SSH, you don't have a screen (at least not one Windows knows how to see): you just have the sshd service - so you can't take a screenshot.
Your login session probably doesn't have permission to use the desktop DC since it isn't part of the desktop.
Edit: If your intent is to get a screenshot of the Cygwin window only, you might be able to use the GetConsoleWindow
function to get the HWND of that window - assuming it exists in a sshd session.
精彩评论