How can I respond to a change in status for a Windows Service?

依然范特西╮ 提交于 2019-12-05 18:27:32
Cody Gray

This is exactly what the NotifyServiceStatusChange function is intended for. The docs say that it:

Enables an application to receive notification when the specified service is created or deleted or when its status changes.

I'm not sure if there's an equivalent event wrapped in managed code, but this one is easy enough to get at using P/Invoke.

However, note that this function is only available in Windows Vista and later. If you need to target earlier versions, you can find a solution in one of the answers to this question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!