延长Windows服务停止的时间

Extend the time the Windows service is stopped

本文关键字:时间 Windows 服务 延长      更新时间:2023-10-16

我需要服务才能停止足够长的时间。大约5-10分钟。现在,在Windows 10上,我的服务系统在60秒后杀死,而无需等待正确完成。使用NET函数requestAdditionaltime看到了C#的类似问题。但是我需要在API上实现C 。

设置注册表中的密钥值不会影响hkey_local_machine system CurrentControlset Control WaittokillService设置为300000

您不应该弄乱全局注册表设置。

停止服务时,请使用SERVICE_STOP_PENDING调用SetServiceStatus,并将dwCheckPointdwWaitHint设置为适当的值。根据dwWaitHint的文档多次致电ServServiceStatus,直到完成并停止服务(SetServiceStatus(h, SERVICE_STOPPED, ...))。