gpt4 book ai didi

installation - 在 Inno Setup 中安装之前检测重启是否挂起

转载 作者:行者123 更新时间:2023-12-04 04:23:39 26 4
gpt4 key购买 nike

如果重新启动/重新启动已经挂起/需要,是否有办法阻止安装?

我们的安装程序会安装 SQL Server Express,如果系统中有挂起的重启,它有时会拒绝安装。 Inno Setup 能否检测到这种情况,以便我可以告诉用户在安装我们的软件之前重新启动?

我知道 MakePendingFileRenameOperationsChecksum但通常会提到检测在安装过程中是否出现需要重新启动的条件。可以在之前使用吗?

最佳答案

如果要检测,是否有挂起的重命名需要重启,查询PendingFileRenameOperations注册表值。

另见 How to find out if an MSI I just installed requested a Windows reboot?

function IsRestartPending: Boolean;
var
S: string;
begin
if RegQueryMultiStringValue(
HKLM, 'SYSTEM\CurrentControlSet\Control\Session Manager',
'PendingFileRenameOperations', S) then
begin
Log(Format('PendingFileRenameOperations value exists with value [%s]', [S]));
Result := (Trim(S) <> ''); { This additional check is probably not needed }
end
else
begin
Log('PendingFileRenameOperations value does not exist');
Result := False;
end;
end;

function InitializeSetup(): Boolean;
begin
if IsRestartPending then
begin
MsgBox('Restart your machine please', mbError, MB_OK);
Result := False;
Exit;
end;

Result := True;
end;

如果您需要测试可能需要重新启动的其他操作,您必须调整@Jerry 为 Inno Setup 提供的答案。

关于installation - 在 Inno Setup 中安装之前检测重启是否挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58439696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com