Running on Windows 7 x64, I have the following code which is working fine when i run it as a stand alone application (such as ConsoleApplication1):
var screen = Screen.PrimaryScreen;
using (var bitmap = new Bitmap(screen.Bounds.Width, screen.Bounds.Height))
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.CopyFromScreen(new Point(screen.Bounds.Left, screen.Bounds.Top), new Point(0, 0),
screen.Bounds.Size);
bitmap.Save(@"c:\\Test.png", ImageFormat.Png);
}
I need to put this code in a "Windows Service" with "Local System Account" and "Allow Service to Interact with Desktop", but when I run it there, it is capturing a black screen.
I understand that in Win7 services are isolated and there is no interaction with desktop, but I need to take screenshot somehow, or pass some admin credentials.
The Windows Service MUST run as "Local System Account" and I cannot change it to run as administrator
How can I still take screenshot?