Screen capture does not work in Windows Service...?

G

Guest

Hi guys,

I have a little problem. I have a class that uses Windows API to capture a
snapshot of the screen. I have this class in a library that I include in my
projects.

When I try to use this class in a windows service, the snapshot comes up as
a black screen. Any idea why? or how do I get around it?

The class works fine if I use it in a regular windows forms application.

Thank you in advance!
 
P

Peter Rilling

Windows services do not interact with the desktop. There is a setting in
the properties for the windows service that allows the service to interact
with the desktop. Try changing this setting. I have not done this before,
but it is a thought.
 
G

Guest

Thank you Peter. This is a good lead. However, I cannot find this setting
anywhere. Can you be more specific?

Thank you!
 
P

Peter Rilling

1) Administrative Tools --> Services
2) Locate your service and right-click. Select the Properties command.
3) Click the Log On tab.
4) Check the Allow service to interact with desktop checkbox.

I don't know if this will work, but it is worth a try.
 
C

Chris Dunaway

But what screen are you trying to capture? If no one is logged on,
then all you might get would be the logon screen?

Perhaps your windows service could detect when a user logged on and
when they did, then kick off a thread or process that would capture the
screen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top