如何在运行Windows服务的系统托盘中显示图标 [英] How do I display icon in system tray of running windows service

查看:347
本文介绍了如何在运行Windows服务的系统托盘中显示图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows服务,它在后台运行,但我想在系统托盘中显示它,以便我可以在托盘中检查它是运行还是停止。并且能够在控制面板中更改其配置。



我怎么能实现这个目标?

事先提前!!

解决方案

< blockquote>嗯......对此的回答是你没有 - 你有两个独立的程序,你的服务和系统托盘应用程序,你在它们之间进行通信 - 使用某种形式的IPC - 例如,命名管道 - 这里是您可能会发现一个有用的讨论 Windows中用户级服务和应用程序之间的交互Vista [ ^ ] - 你也可以使用TCP / IP套接字等



你也可以(从系统托盘应用程序)发出'自定义命令'到通过SCM服务



[修改]

自定义命令的两个链接是 https://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.executecommand(V = vs.110) .aspx [ ^ ]和 https://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.oncustomcommand(v = vs.110).aspx [ ^ ] [/ modified]



'g'


I have one Windows service which is running in background sucsessfully but i want to show it in system tray so that i can check it in tray whether it is running or stoped. and able to change its configuration as like in control panel.

How could I achieve this?
Thnks in advance!!

解决方案

Well ... an answer to this is 'you don't' - you have two separate programs, your service and a system tray app and you communicate between them - using some form of IPC - for example, named pipes - here's one discussion you may find useful Interaction between services and applications at user level in Windows Vista[^] - you can also uses TCP/IP sockets etc

You can also (from the System Tray App) issue 'custom commands' to the service through the SCM

[modified]
The two links for Custom Commands are https://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.executecommand(v=vs.110).aspx[^] and https://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.oncustomcommand(v=vs.110).aspx[^] [/modified]

'g'


这篇关于如何在运行Windows服务的系统托盘中显示图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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