[英]Inno Setup: How to overwrite on install but not on change?
I know how to overwrite the files using this method我知道如何使用这种方法覆盖文件
[Files]
Source: "Project\*"; DestDir: "{app}"; \
Flags: ignoreversion recursesubdirs onlyifdoesntexist; Permissions: everyone-full
But when I change the program using the Change option in 'Install Or Change Program' section I want to not overwrite the files.但是,当我使用“安装或更改程序”部分中的更改选项更改程序时,我不想覆盖文件。
I create the change option for my installer like this:我为我的安装程序创建了更改选项,如下所示:
[setup]
AppModifyPath="{srcexe}" /modify=1
How do I do this?我该怎么做呢?
First, your code seems wrong.首先,您的代码似乎错误。 With the onlyifdoesntexist
flag , the files are never overwritten, contrary to what you claim.使用onlyifdoesntexist
标志,文件永远不会被覆盖,这与您声称的相反。 So for most purposes, simply using this flag will do.因此,对于大多数目的,只需使用此标志即可。
Anyway, a solution is to create two [Files]
entries, one that overwrites and one that does not.无论如何,一种解决方案是创建两个[Files]
条目,一个覆盖,一个不覆盖。 And use the Pascal scripting to pick the entry for a respective installation mode.并使用 Pascal 脚本选择相应安装模式的条目。
[Files]
Source: "Project\*"; DestDir: "{app}"; Flags: ... onlyifdoesntexist; Check: IsUpgrade
Source: "Project\*"; DestDir: "{app}"; Flags: ...; Check: not IsUpgrade
Example of IsUpgrade
implementation: IsUpgrade
实施示例:
[Code]
function IsUpgrade: Boolean;
var
S: string;
InnoSetupReg: string;
AppPathName: string;
begin
InnoSetupReg :=
'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#SetupSetting("AppId")}_is1';
{ 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(InnoSetupReg);
AppPathName := 'Inno Setup: App Path';
Result :=
RegQueryStringValue(HKLM, InnoSetupReg, AppPathName, S) or
RegQueryStringValue(HKCU, InnoSetupReg, AppPathName, S);
end;
See also Pascal scripting: Check parameters .另请参阅Pascal 脚本:检查参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.