gpt4 book ai didi

c# - 窗口服务的通知图标

转载 作者:可可西里 更新时间:2023-11-01 07:45:57 26 4
gpt4 key购买 nike

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

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

最佳答案

从 Vista 开始,您的服务将不允许与桌面交互,因此不能直接在服务外运行 UI。您需要构建一个在用户登录时启动的代理应用程序,该应用程序可以与您的服务聊天(可能使用 WCF)。

这是MS have to say关于这样做:

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.

关于c# - 窗口服务的通知图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12857191/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com