我不知道是否有任何可能的方式来获取或状态改变Windows服务的创建活动。
I wonder if there is any possible way to get or create an event for a status changed of a Windows Service.
我知道的ServiceController
类没有的情况下,但它的地位。有没有什么办法,我可以听一个事件?
I know that the ServiceController
class does not have the event, but it has the status. Is there any way that I can listen to an event?
这正是的 NotifyServiceStatusChange
功能仅供。该文档说的:
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.
我不知道是否有等效事件裹在管理code,但是这个人是很容易获得,在使用P / Invoke。
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.
不过,请注意,此功能仅在Windows Vista及更高版本。如果您需要针对早期版本中,你可以找到答案的一个解决方案,this问题。
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.
上一篇:是否有可能的属性添加到ExpandoObject实例产生的成员?有可能、实例、属性、成员
下一篇:什么时候应该使用UdpClient.BeginReceive?什么时候应该使用UdpClient.Receive在后台线程?什么时候、线程、后台、BeginReceive