Windows 服务控制字符

发布于 2024-10-09 12:12:38 字数 128 浏览 0 评论 0原文

我创建了一个 Windows 服务,并想向其发送 control+B 或 control+C 控制值。我知道我可以使用 sc 控制,但我想知道是否有一个位置包含我可以发送的所有可能值。有一个 sc stop 方法,但我想向它发送一个控制字符。

I created a Windows service and would like to send it a control+B or control+C control value. I know I can use sc control, but I was wondering if there was a location that contained all possible values I can send. There is a sc stop method, but I'm looking to send it a control character.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埋葬我深情 2024-10-16 12:12:38

服务关闭的“优雅”程度完全取决于您的服务如何响应请求。如果您正在编写服务,那么您可以完全控制当 SCM 发送“停止”请求时您的服务如何响应。收到请求后,您有有限的时间(Windows 决定多少时间)来停止服务并响应控制请求。如果您未能及时响应,Windows可能会非正常终止您的服务进程。

控制台应用程序可以使用 SetConsoleCtrlHandler() 函数。但是,服务进程不在控制台窗口内运行,因此该处理程序完全不适用于服务。

The "gracefulness" of a service shutdown all depends on how your service responds to the request. If you're writing the service, then you have full control over how your service responds when the SCM sends a "stop" request. After receiving the request, you have a limited amount of time (Windows decides how much) to stop your service and respond to the control request. If you fail to respond in a timely manner, Windows may terminate your service process ungracefully.

A console application can respond to a Ctrl+C request using the SetConsoleCtrlHandler() function. However, service processes are not run inside a console window, so this handler is completely unapplicable to services.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文