简体   繁体   English

在Windows服务中选中“允许服务与桌面交互”(在服务属性中)

[英]Find “Allow service to interact with desktop” checked (in the service properties) of Windows Service

I use Capture Screen in windows services all of codes worked correctly in win form but in win service that return a black picture SO I search and find this and try to find "Allow service to interact with desktop" checked (in the service properties) but there isn't any property with that name. 我在Windows服务中使用捕获屏幕所有代码在win形式下正常工作但在win服务中返回黑色图片所以我搜索并找到这个并尝试查找“允许服务与桌面交互”选中(在服务属性中)但没有任何具有该名称的财产。 Is there any idea about it? 有什么想法吗? how/where I can find it? 怎么/在哪里可以找到它? I use Windows Server 2008 R2 SP1 and VS2010 and C#4 and if there isn't any property in this version how can I do? 我使用Windows Server 2008 R2 SP1和VS2010以及C#4,如果此版本中没有任何属性,我该怎么办?

That setting is a legacy setting that won't solve your problem. 该设置是遗留设置,无法解决您的问题。 Starting from Vista your service does not have access to the interactive desktop and you will need to perform the screen capture from a standard app running on the interactive desktop. 从Vista开始,您的服务无法访问交互式桌面,您需要从交互式桌面上运行的标准应用程序执行屏幕捕获。

You can use an IPC mechanism to communicate between your service and the desktop app. 您可以使用IPC机制在服务和桌面应用程序之间进行通信。 You can start this desktop app from a service but it's rather tricky to do, as explained here . 您可以从服务这个桌面应用程序,但它是相当棘手的事,因为解释在这里

Checking the "Allow service to interact with desktop" just means you can call interactive API functions without error. 选中“允许服务与桌面交互”只意味着您可以无错误地调用交互式API函数。 You don't get access to the inreractive desktop. 您无法访问inreractive桌面。 This issue all stems from changes introduced in Vista that mean services run in an isolated session, session 0. 这个问题都源于Vista中引入的更改,这意味着服务在隔离会话(会话0)中运行。

To set this property you have to open the windows service managment, right click your service and open the properties. 要设置此属性,您必须打开Windows服务管理,右键单击您的服务并打开属性。 after that select the "log on" tab. 之后选择“登录”选项卡。 when your service runs under local system you can select "Allow service to interact with desktop". 当您的服务在本地系统下运行时,您可以选择“允许服务与桌面交互”。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM