Windows service couldnt get screenshot in windows 7

前端 未结 2 671
清酒与你
清酒与你 2020-11-29 13:09

I have a windows service which gets the screenshots. But its creating only black screens. I know this happens because of session 0 isolation. I searched on internet and coul

相关标签:
2条回答
  • 2020-11-29 13:24

    a windows service is designed to run also when there are no users connected, it works like a server process always up and listening, or up and doing something, or idle.

    I think what you need is a client application which runs inside every logged user' session and eventually does the job then, if needed, communicates with the service to carry some job done.

    I am saying here that instead of having the windows service running in another session than 0 you can create a small executable (probably with no UI at all) that starts up from the start up folder of all users at every user login. such application is then running inside the proper session and has access to it, it can get the screenshot then either store it somewhere itself or call some end points in your Windows Service (running always in session 0) and make the service to elaborate the screenshot taken from the client application of it.

    this is the way I would do it, not trying some "magic" to tell Vista and 7 to start a service inside a session of a user that in the end is not logged in yet when the system starts.

    0 讨论(0)
  • 2020-11-29 13:36

    Is there a way to change the session of a windows service and get the desktop screen of another user's session like session 1, session 2?

    No.

    Is there a way to start a console application which runs in an another session other than session 0 from a windows service?

    This can be done but it's messy. It involves impersonation of the logged on user, manipulation of user tokens, and launching a process into a different session with CreateProcessAsUser(). This article describes what is needed.

    As an aside, you don't want a console application because that will splat a console window on your screenshot. You just want a standard Windows app (using the GUI subsystem) but one that does not show any visible windows.

    0 讨论(0)
提交回复
热议问题