Inno Setup 日志设置退出代码

Inno Setup Log setup exit code

默认情况下,Inno 安装程序日志文件不包含安装程序退出代码。我正在寻找一种将其包含在日志文件中的方法。我假设这将使用 Log 函数完成并将其包含在 DeinitializeSetup 事件中。像这样:

procedure DeinitializeSetup();
begin
  Log('Exit code: ' + ExitCode);
end;

我不知道,而且似乎找不到的是如何 return 设置退出代码,以便我可以在 Log 函数中使用它。这是最好的方法吗?我如何 return 设置退出代码?

无法在 Pascal 脚本中检索退出代码。

您所能做的就是记录安装是否成功(反正已经记录了)。

一种方法是检查 the GetCustomSetupExitCode event function 是否被调用(当退出代码仅为 0 时被调用)。

var
  ZeroExitCode: Boolean;

function GetCustomSetupExitCode: Integer;
begin
  ZeroExitCode := True;
  Result := 0;
end;

procedure DeinitializeSetup();
begin
  if ZeroExitCode then
    Log('Zero exit code')
  else
    Log('Non-zero exit code');
end;