Screen capture from windows service

我怕爱的太早我们不能终老 提交于 2019-11-27 19:56:30

Try this in addition to allowing access to the desktop:

  1. Enumerate all Window Stations: EnumWindowStations
  2. Find the window station for the logged on user, and make it your process' window station: SetProcessWindowStation - see example in this thread
  3. Then set the desktop for your current thread to the default desktop of the window station also here
  4. Then get the DC of the desktop using one of a few methods, including

    CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL)

    Good luck

As I understand it, a change was made in Vista that moved services onto a separate desktop from the console user. While you have ticked the box that "allows access" to the desktop, I think you still have to pragmatically switch your service to use that desktop.

Here is a blog post with some useful info and examples.

Have you tested that the desktop application succeeds on the same computers it fails as a service?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!