Screen capture from windows service
c#, c++, screen-capture, windows-services
Solution
Try this in addition to allowing access to the desktop:
- Enumerate all Window Stations: EnumWindowStations
- Find the window station for the logged on user, and make it your process' window station: SetProcessWindowStation - see example in this thread
- Then set the desktop for your current thread to the default desktop of the window station also here
Then get the DC of the desktop using one of a few methods, including
CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL)
Good luck
Problem
I've got DirectShow based screen capture software. Internally it calls CopyScreenToBitmap function to grab screen. Then the picture is compressed by ffdshow. It works fine as a desktop application, but as window service, on certain computers it does not work (black picture). I've set 'Allow service to interact with desktop' and run that service on current user account. Any ideas what could be wrong? I test it on windows XP, but it is expected to work on Vista and 7 as well. Yes it works as desktop application on all computers, but on some of them (on majority of them) it fails as a service.