简体   繁体   English

用Windows服务运行UI

[英]running UI with windows service

i am planning to run a launch/monitor a UI application using a windows service(written in C#).with "Allow service to interact with desktop " checked. 我计划使用Windows服务(用C#编写)运行启动/监视UI应用程序。选中“允许服务与桌面交互”。 this works fine with windows xp, but with windows 7 a pop is shown as below 这适用于windows xp,但是对于Windows 7,pop如下所示

在此输入图像描述

and when i click on view the message , then the whole screen blanks out,with only UI showing up ,as shown below. 当我点击查看消息时,整个屏幕显示空白,只显示UI,如下所示。

在此输入图像描述

is there any way to make it work without the message being shown and screen going blank. 有没有办法让它工作,没有显示消息,屏幕变成空白。

comments/suggestions appreciated. 意见/建议表示赞赏。

Regards DEE 关心DEE

In Vista and later, services cannot interact with the desktop. 在Vista及更高版本中,服务无法与桌面交互。 Services run under what is known as session 0 isolation . 服务在所谓的会话0隔离下运行。 What you are attempting is simply impossible. 你在尝试什么是根本不可能的。

You will have to re-write your application so that the UI part resides in a standard Windows application that runs on the logged in user's desktop. 您必须重新编写应用程序,以便UI部件驻留在登录用户桌面上运行的标准Windows应用程序中。 This UI part can communicate with the service by whatever IPC mechanism you prefer. 此UI部分可以通过您喜欢的任何IPC机制与服务进行通信。

"Allow service to interact with desktop " is a legacy option that is now highly discouraged, and although it exists, is not expected to work in Windows Vista and upwards. “允许服务与桌面交互”是一种遗留选项,现在非常不鼓励,尽管它存在,但预计不会在Windows Vista及更高版本中运行。

You need to read a bit on why this is the case in this other SO answer: 您需要阅读一下为什么在其他SO答案中出现这种情况:
Allow service to interact with desktop in Windows 允许服务与Windows中的桌面交互

Then look for the alternatives discussed in the answer here: 然后在这里找到答案中讨论的替代方案:
Alternative to "Allow service to interact with desktop"? “允许服务与桌面交互”的替代方案?

Another discussion outside SO: SO之外的另一个讨论:
http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/f8f91e8f-5954-43a7-8bc4-80ed2ff1e3b1/ http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/f8f91e8f-5954-43a7-8bc4-80ed2ff1e3b1/

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

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