阻止Windows服务管理器停止服务C# [英] Prevent Windows service manager from stopping a service c#

查看:34
本文介绍了阻止Windows服务管理器停止服务C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有自己的注册处理程序的自定义Windows服务,当它从服务管理器收到stop命令时,如何防止它停止?我在服务和GUI之间建立了管道通信,当我向Windows服务发送消息停止"而不是尝试从Windows服务管理器停止它时,我仅想从GUI停止它.我在C#中工作

I have a custom windows service with my own register handler, how can I prevent it from stopping when it receives the stop command from the services manager ? I established a pipe communication between the service and a GUI and I want to stop it only from the GUI, when I send the windows service the message "stop" not when I try to stop it from windows service manager. I am working in C#

推荐答案

这是否回答了您的问题?

Does this answer your question?

http://bytes.com/topic/c-sharp/answers/444965-prevent-service-stopping

将CanStop属性设置为false.然后,您将需要一个用户可以用来请求停止的应用程序.然后,该应用将与您的服务通信(也许通过远程通信),如果条件允许,请自行停止.您应该可以通过动态地将'CanStop'设置为true,然后使用ServiceController类连接到自己并发出'Stop'命令来做到这一点.

这篇关于阻止Windows服务管理器停止服务C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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