通知图标窗口服务 [英] Notify Icon for Window Service

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

问题描述

我已经开发了双赢的服务程序,它从我的本地驱动器读取Excel文件,然后这个文件的值保存到数据库,现在我想开发一个通知图标,这将是显示屏显示的消息(Excel文件保存在数据库)后,我的服务将启动,并保存Excel文件数据库中。

I have developed win service program which reads a excel file from my local drive and then save this file values to database and now I want to develop a notify icon which will be display to show a message("Excel File Saved In Database") after my service will start and will save excel file to database.

请给我一些提示来解决这个问题。

Please give me some hints to solve this.

推荐答案

从Vista开始,您的服务将不会被允许与桌面交互,所以不能有UI直接捉迷藏了服务。你需要建立在用户登录启动代理应用程序,可以聊天,为您服务,可能使用WCF

From Vista onwards, your service will not be allowed to interact with the desktop, so cannot have a UI runnning directly out of the service. You need to build an agent application that starts up at user login that can chat to your service, probably using WCF.

下面是什么的MS不得不说这个干什么

有关更复杂的交互,开发者应该将他们的UI代码到用户的会话中运行并处理所有​​UI要求代理。代理通过RPC或命名管道服务进行通信。如果用户通过使用控制面板,Internet Explorer或类似的UI体验启动UI交互,即用户界面体验应该启动代理。然后,代理处理所有UI交互。如果需要的UI,但不能由用户发起的,该服务必须请求该代理启动任何所需的用户界面中,而不是试图通过自身来启动该用户界面。在极少数情况下该服务必须启动用户交互和代理尚未运行,服务应该调用CreateProcessAsUser API启动代理。然后,代理可以启动所有UI交互。为开发者仔细审查所有可能的使用场景,并考虑将所有的UI代码到在用户会话中运行的一个代理是很重要的。

For more complex interactions, developers should move their UI code into an agent that runs in the user’s session and handles all UI requirements. The agent communicates with the service through RPC or named pipes. If the user initiates the UI interaction by using Control Panel, Internet Explorer, or a similar UI experience, that UI experience should start the agent. The agent then handles all UI interactions. If UI is required but is not initiated by the user, the service must request the agent to start any required UI, instead of attempting to launch that UI by itself. In the rare situation where the service must initiate a user interaction and the agent is not already running, the service should call the CreateProcessAsUser API to start the agent. The agent can then initiate all UI interactions. It is important for developers to carefully review all possible usage scenarios and consider moving all UI code into an agent that runs in the user session.

这篇关于通知图标窗口服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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