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.
精彩评论