I'm trying to write an exe that will capture a screen on windows and save it into a bitmap file.
I'm using GDI, and I've managed to do it now using the GetDC function. in a nutshell, it is something like that:
HDC desktopDC = GetDC(NULL);
HDC memDC = CreateCompatibleDC (desktopDC);
HBITMAP ScreenBitmap = CreateCompatibleBitmap(desktopDC,DesktopWidth,DesktopHeight);
of course, this kind of code is good only if I run my program in interactive mode, and it capture the desktop that I can see. however, I need to run this program as a service, which means it will be in the context of the LOCAL SYSTEM user, and won't have a desktop. what I want it to do, is to find the desktop of a specified user session (which I know that it is connected), and capture it.
is that possible? (programmtically, not from the security point of view)
does anyone know how it can be done? how can I get a DC of a different session that myself?