如果在 Inno Setup 中更新安装,则排除 ssPostInstall 步骤中的部分代码部分
Excludes part of Code section in ssPostInstall step if installation is update in Inno Setup
我尝试对两者(全新安装和更新)使用相同的安装程序。
- 因此,如果用户第一次尝试安装我的应用程序,它将 运行 完整安装包括 MySQL 安装程序作为先决条件,以及 MySQL 安装的一部分
[Code]
会正常执行。
- 但是,如果用户已经安装了我的应用程序,并且安装程序是较新版本(更新),则不应执行
[Code]
中的 MySQL 安装部分。
那么,如果安装只是更新,这部分代码(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;
我尝试对两者(全新安装和更新)使用相同的安装程序。
- 因此,如果用户第一次尝试安装我的应用程序,它将 运行 完整安装包括 MySQL 安装程序作为先决条件,以及 MySQL 安装的一部分
[Code]
会正常执行。 - 但是,如果用户已经安装了我的应用程序,并且安装程序是较新版本(更新),则不应执行
[Code]
中的 MySQL 安装部分。
那么,如果安装只是更新,这部分代码(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;