I use Capture Screen in windows services all of codes worked correctly in win form but in win service that return a black picture SO I search and find this and try to find "Allow service to interact with desktop" checked (in the service properties) but there isn't any property with that name. Is there any idea about it? how/where I can find it? I use Windows Server 2008 R2 SP1 and VS2010 and C#4 and if there isn't any property in this version how can I do?
Find "Allow service to interact with desktop" checked (in the service properties) of Windows Service
-
possible duplicate of [windows service (allow service to interact with desktop)](http://stackoverflow.com/questions/4237225/windows-service-allow-service-to-interact-with-desktop) – Cody Gray - on strike Dec 22 '11 at 13:00
-
1The real question to be asked here is why [you think] you need a Windows Service in the first place. Yes, you can use David's solution and grit your teeth trying to get IPC to work to communicate between a standard user-mode app and a service, but there's hardly ever a point. Just create a standard Windows application that *doesn't display a window*. You'll have all the benefits of a service without the limitations (from your perspective). It's a very specialized case indeed where someone really needs a Windows Service. I don't know why everyone thinks they do. – Cody Gray - on strike Dec 22 '11 at 13:04
2 Answers
That setting is a legacy setting that won't solve your problem. Starting from Vista your service does not have access to the interactive desktop and you will need to perform the screen capture from a standard app running on the interactive desktop.
You can use an IPC mechanism to communicate between your service and the desktop app. You can start this desktop app from a service but it's rather tricky to do, as explained here.
Checking the "Allow service to interact with desktop" just means you can call interactive API functions without error. You don't get access to the inreractive desktop. This issue all stems from changes introduced in Vista that mean services run in an isolated session, session 0.

- 601,492
- 42
- 1,072
- 1,490
To set this property you have to open the windows service managment, right click your service and open the properties. after that select the "log on" tab. when your service runs under local system you can select "Allow service to interact with desktop".
-
1Windows XP!! That's so 10 years ago. The checkbox doesn't work anymore. It's time to upgrade to a modern version of Windows. – Cody Gray - on strike Dec 22 '11 at 12:58
-
2@lmw you can check the box on win 7, it just doesn't do what you think it does – David Heffernan Dec 22 '11 at 13:00
-
i have developed several OPC-services at my company and everyone of them needed this property. if it's not checked the service is not able to open other processes on the local machine in the foreground (i mean with showing up a winform, not only a background process). but it sounds interesting, do you have a link or blogpost regarding your thesis? – LMW-HH Dec 22 '11 at 13:04
-
1Explained in great detail here, including pretty pictures: http://stackoverflow.com/a/4516515/366904 And check all the links in the "related" section. David and I didn't invent this. – Cody Gray - on strike Dec 22 '11 at 13:05
-
1
-
thank you both! that's the problem with old code that get's older without refactoring i think. the first time i saw it was 5 years ago and if i know it right it's still the same. i will lead this stuff to my excolleagues :) – LMW-HH Dec 22 '11 at 13:16