问题描述
我已经写了窗口服务,并设置其启动类型设置为自动。但安装后服务的用户可以更改其类型为已禁用。
I have written a windows service and has set its startup type to be 'Automatic'. But after installing the service a user can change its type to 'disabled'.
有没有办法通过,我可以服务在安装后识别该服务的状态?我可以防止用户更改启动类型,以便它永远是自动?
Is there a way by which I can identify the status of this service after service installation? Can I prevent a user from changing the startup type so that it will always be 'Automatic'?
感谢
推荐答案
有是这样做没有API,但你可以在注册表中检查该服务启动模式,在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName\Start。该值将是2(自动),3(手动),或4(禁用)。
There is no API for doing this, but you can check the service start mode in the registry, at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName\Start. That value will be either 2 (automatic), 3 (manual), or 4 (disabled).
这篇关于获取Windows服务的状态残疾人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!