从Windows服务的抓屏 [英] Screen capture from windows service

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

问题描述

我已经有了基于DirectShow的屏幕捕捉软件。在内部调用CopyScreenToBitmap功能抓取屏幕。然后画面融为一体pressed通过ffdshow的。
它工作正常,作为一个桌面应用程序,但作为窗口服务,在某些计算机不工作(黑色画面)。我设置允许服务与桌面交互,并运行在当前用户帐户的服务。
任何想法可能是错误的?

I've got DirectShow based screen capture software. Internally it calls CopyScreenToBitmap function to grab screen. Then the picture is compressed by ffdshow. It works fine as a desktop application, but as window service, on certain computers it does not work (black picture). I've set 'Allow service to interact with desktop' and run that service on current user account. Any ideas what could be wrong?

我测试它在Windows XP,但预计在Vista上工作,7为好。

I test it on windows XP, but it is expected to work on Vista and 7 as well.

是的,它可以作为所有计算机上的桌面应用程序,但他们中的一些(对大多数人)没有作为一个服务。

Yes it works as desktop application on all computers, but on some of them (on majority of them) it fails as a service.

推荐答案

除了尝试使用此方法允许访问桌面:

Try this in addition to allowing access to the desktop:


  1. 枚举所有窗口站: EnumWindowStations

  2. 找到了登录用户的窗口站,并让它成为你进程的窗口站:的 SetProcessWindowStation - 例如参见<一个href=\"http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/967f4cba-bd2a-4f90-a8d2-9c335fa57936\"相对=nofollow> 在这个线程

  3. 然后你当前线程设置桌面窗口站的默认桌面<一个href=\"http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/967f4cba-bd2a-4f90-a8d2-9c335fa57936\"相对=nofollow> 也在这里

  4. 然后得到使用的一些方法之一,包括桌面的DC

  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)

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

好运气

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

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