开发者

Windows Listen to service Status Changed

开发者 https://www.devze.com 2023-04-10 07:42 出处:网络
How Can I make an app that listens to services for Service Status Changed event. (I don\'t want repeated checking on of all servic开发者_高级运维es)

How Can I make an app that listens to services for Service Status Changed event. (I don't want repeated checking on of all servic开发者_高级运维es)

EDIT

I need it to work on Windows XP / 2000


In Vista and above you can use NotifyServiceStatusChange API. See some sample code on MSDN.

If you are monitoring more than one service, you will have to call NotifyServiceStatusChange for each service you want to have monitored.


You are looking for NotifyServiceStatusChange which requires Vista. On 2000/XP you will need to poll.


You could use WMI with something like SELECT * FROM __InstanceModificationEvent WHERE TargetInstance ISA 'Win32_Service' and then checking the State field of the Win32_Service class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号