C# - Screenshot of process under Windows Service
Posted
by Jonathan.Peppers
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan.Peppers
Published on 2009-09-18T17:10:47Z
Indexed on
2010/05/19
8:10 UTC
Read the original article
Hit count: 750
We have to run a process from a windows service and get a screenshot from it.
We tried the BitBlt and PrintWindow Win32 calls, but both give blank (black) bitmaps.
If we run our code from a normal user process, it works just fine.
Is this something that is even possible? Or could there be another method to try?
Things we tried:
- Windows service running as Local System, runs process as Local System -> screenshot fails
- Windows service running as Administrator, runs process as Administrator -> screenshot fails.
- Windows application running as user XYZ, runs a process as XYZ -> screenshot works with both BitBlt or PrintWindow.
- Tried checking "Allow service to interact with desktop" from Local System
We also noticed that PrintWindow works better for our case, it works if the window is behind another window.
For other requirements, both the parent and child processes must be under the same user. We can't really use impersonation from one process to another.
© Stack Overflow or respective owner