如果在 Inno Setup 中更新安装,则排除 ssPostInstall 步骤中的部分代码部分

Excludes part of Code section in ssPostInstall step if installation is update in Inno Setup

我尝试对两者(全新安装和更新)使用相同的安装程序。

那么,如果安装只是更新,这部分代码(MySQL安装)如何实现异常功能?

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
{ ... }
begin
  if CurStep = ssPostInstall then
  begin
    { fresh installation code }
  end;
end;

你可以使用我对
的回答中的IsUpgrade功能 Can Inno Setup respond differently to a new install and an update?:

尽管它依赖于 "Uninstall" 注册表项的存在,该注册表项在 ssPostInstall 时已经存在,但您必须缓存其值。

var
  IsUpgradeCached: Boolean;

function InitializeSetup(): Boolean;
begin
  IsUpgradeCached := IsUpgrade;
  Result := True;
end;

procedure CurStepChanged(CurStep: TSetupStep);
{ ... }
begin
  if (CurStep = ssPostInstall) and (not IsUpgradeCached) then
  begin
    { fresh installation code }
  end;
end;