windows API & background processes

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
I'm running a GUI app as SYSTEM user from a web server script, and I'm trying to get a screenshot. My code for the screenshot taker is here (note that it takes the shot on WM_SIZE, which occurs right after the app launches... a hack, but it will be adequate for now). When I run the app interactively, it takes a screenshot and saves it properly. However, as a SYSTEM process in the background, it does the following:

if hWND=GetDesktopWindow(), produces an ERROR_INVALID_HANDLE in BitBlt

if hWND = GetForegroundWindow/FindWindow, produces an ERROR_INVALID_WINDOW_HANDLE in GetWindowRect

Is there a way to do what I'm trying to do?