Windows服务下进程截图 [英] Screenshot of process under Windows Service

查看:66
本文介绍了Windows服务下进程截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们必须从 Windows 服务运行一个进程并从中获取屏幕截图.

We have to run a process from a windows service and get a screenshot from it.

我们尝试了 BitBlt 和 PrintWindow Win32 调用,但都给出了空白(黑色)位图.

We tried the BitBlt and PrintWindow Win32 calls, but both give blank (black) bitmaps.

如果我们从普通用户进程运行我们的代码,它就可以正常工作.

If we run our code from a normal user process, it works just fine.

这是可能的吗?或者还有其他方法可以尝试吗?

Is this something that is even possible? Or could there be another method to try?

我们尝试过的事情:

  1. Windows 服务作为本地系统运行,进程作为本地系统运行 -> 截图失败
  2. 以管理员身份运行的 Windows 服务,以管理员身份运行进程 -> 截图失败.
  3. 以 XYZ 用户身份运行的 Windows 应用程序,以 XYZ 身份运行进程 -> 屏幕截图适用于 BitBlt 或 PrintWindow.
  4. 尝试从本地系统选中允许服务与桌面交互"

我们还注意到 PrintWindow 更适合我们的情况,如果窗口在另一个窗口后面,它也能工作.

We also noticed that PrintWindow works better for our case, it works if the window is behind another window.

对于其他要求,父进程和子进程必须在同一用户下.我们不能真正使用从一个进程到另一个进程的模拟.

For other requirements, both the parent and child processes must be under the same user. We can't really use impersonation from one process to another.

推荐答案

我认为这不可能.

我们不得不改变我们的应用程序不是从服务启动的场景,而是一个标准的 Windows 程序,在角落里有一个 NotifyIcon.

We had to change our scenario where our application wasn't started from a service, but was a standard windows program that has a NotifyIcon in the corner.

如果有人仍然找到真正的答案,请告诉我.

If someone still finds a real answer, let me know.

这篇关于Windows服务下进程截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆