且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

验证服务是否被标记为删除

更新时间:2023-12-05 21:36:46

一般来说,这种情况发生在某些内容仍然锁定在该服务上,阻止 Windows 删除其在注册表中的配置时.(在大多数情况下,它只是服务小程序 -- services.msc -- 在后台意外打开.)

Generally speaking, this scenario occurs when something remains latched onto that service, preventing Windows from removing its configuration in the registry. (In most cases, it's simply the Services applet -- services.msc -- left open by accident in the background.)

对于检测,我建议您阅读 CreateService 和其他服务 API.例如,如果服务被标记为删除,您将在调用 CreateService 时收到 ERROR_SERVICE_MARKED_FOR_DELETE.

For detection, I suggest you read up on CreateService and other Service API. For example, you'll receive ERROR_SERVICE_MARKED_FOR_DELETE upon calling CreateService if the service is marked for deletion.

关于您提议的重启解决方案... Windows 已经进步到几乎不需要以任何理由重启.除非您正在安装专门的内核驱动程序,否则您不需要重新启动.不要偷懒!把用户放在心上!我建议更改安装程序逻辑以检测可能存在冲突的正在运行的程序,例如服务小程序,并建议关闭.

Regarding your proposed reboot solution... Windows has advanced far enough to not require a reboot for nearly any reason. Unless you're installing specialized kernel drivers, you do not need to reboot. Don't be lazy! Keep the user in mind! I recommend altering your installer logic to detect potentially conflicting running programs, like the Services applet, and suggest closure.