我知道如何使用此方法覆盖文件
[Files]
Source: "Project\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs onlyifdoesntexist; Permissions: everyone-full
但是当我使用“安装或更改程序”中的“更改”选项更改程序时我想不要覆盖文件。
我为我的安装程序创建了更改选项,如下所示:
[setup]
AppModifyPath="{srcexe}" /modify=1
我该怎么做?
答案 0 :(得分:1)
首先,你的代码似乎错了。使用onlyifdoesntexist
标志,文件永远不会被覆盖,与您声称的相反。
无论如何,解决方案是创建两个[Files]
条目,一个覆盖,一个不覆盖。并使用Pascal脚本来选择相应安装模式的条目。
[Files]
Source: "Project\*"; DestDir: "{app}"; Flags: ... onlyifdoesntexist; ...; Check: IsUpgrade
Source: "Project\*"; DestDir: "{app}"; Flags: ...; ...; Check: not IsUpgrade
IsUpgrade
实施示例:
[Code]
function IsUpgrade: Boolean;
var
S: string;
InnoSetupReg: string;
AppPathName: string;
begin
{ The ExpandConstant is here for Inno Script Studio, }
{ which generated AppId in a form of GUID. }
{ The leading { of the GUID has to be doubled in Inno Setup, }
{ and the ExpandConstant collapses that back to single {. }
InnoSetupReg :=
ExpandConstant(
'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppId")}_is1');
AppPathName := 'Inno Setup: App Path';
Result :=
RegQueryStringValue(HKLM, InnoSetupReg, AppPathName, S) or
RegQueryStringValue(HKCU, InnoSetupReg, AppPathName, S);
end;