题
是否有一种方法来通知特定服务被禁用? 我有一个NT服务,我想“抓住”这个事件并保留那个时间以供以后使用。
对如何执行此操作的任何想法?
感谢
解决方案
You ought to be able to do something in WMI to do with that. I think that you can subscribe to the __InstanceModificationEvent
notification for the particular instance of Win32_Service
that you're interested in.
On the other hand, if someone's going to stop and disable the service, they'll just stop and disable the process monitoring it. So you're not going to win, anyway.
Why don't you just secure the service ACL so that only Administrators can stop and disable it? This is, in fact, the default anyway. And if the user's got admin privileges, you've already lost.
其他提示
other parts of my client app will poll and call RegNotifyChangeKeyValue to see if the service is disabled, it is I will make note of it...