Nofity 用户来自 Windows 服务的一些消息 [英] Nofity User some message from a windows service
本文介绍了Nofity 用户来自 Windows 服务的一些消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个 Windows 服务,它从数据库中获取 soem 信息,我想根据从数据库中检索到的信息通知用户.如何使用系统托盘通知从 Windows 服务通知用户?您能否向我展示一些示例(使用 IPC 机制)以获取系统托盘通知中 Windows 服务中使用的方法的返回值?提前致谢.
I have created a windows service which gets soem info from database and I want to notify user based on the info retreived from the DB. How can I notify user from a windows service using system tray notification? Can you please show me some sample (using IPC mechanism) to get the return value of a method used in a windows service in a system tray notification? Thanks in advance.
推荐答案
有几个选项,例如:
- 套接字:(不太难写,有防火墙问题)你几乎可以在任何地方找到它的示例.
- 外部 WinForm:(最简单的方法,有安全问题,可能被一些防病毒应用程序)只需创建一个能够进入的 winFormWindows 通知区域,然后告诉服务运行它的exe文件.
- 命名管道:(可能是最难的,但它是推荐的解决方案)这是一个代码项目示例.
- 其他技巧,例如:创建一个隐藏的 winform 项目 (ShowInTask=false) 并将其放入 StartUp.为它提供一个 FileSystemWatcher 对象,并让它监视服务创建或删除它以向 winform 发出信号的某个文件.
- Sockets: (Not too difficult to write, has firewall problems) You can find samples for it almost everywhere.
- External WinForm: (The easiest method, has security problems and might blocked by some antivirus apps) Just create a winForm with the ability to go into the windows notification area and then tell the service to run its exe file.
- Named Pipes: (Probably the most difficult, but it's the recommended solution) Here is a Code Project sample.
- Other tricks like: Create a hidden winform project (ShowInTask=false) and put it in StartUp. provide it with a FileSystemWatcher object and make it watch for a certain file which the service creates or deletes it to signal the winform.
这篇关于Nofity 用户来自 Windows 服务的一些消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文