这可能是由于Inno Setup升级时未覆盖全局变量而导致的。
可以尝试使用另一个版本的Inno Setup或使用以下代码:
在[Files]部分,将UpdateDestDir设置为应用程序的文件夹:
Source: "Update*"; DestDir: "{app}"; UpdateDestDir: "{app}"
在代码中确保覆盖文件:
[Code] function NeedToCopy(AFileName: String): boolean; var Source: String; Dest: String; begin Result := False; Source := ExpandConstant('Update' + AFileName); Dest := ExpandConstant('{app}' + AFileName); if FileExists(Dest) and (GetFileVersion(Source) <> GetFileVersion(Dest)) then begin Result := True; end; end;
procedure InstallUpdateFiles(); var i: Integer; FileName: String; begin for i := 0 to UpdateFiles.Count-1 do begin FileName := UpdateFiles[i]; if NeedToCopy(FileName) then begin Log(Format('Copying file from update: %s', [FileName])); if not FileCopy(ExpandConstant('Update' + FileName), ExpandConstant('{app}' + FileName), False) then Log(Format('ERROR copying file from update: %s', [FileName])); end; end; end;
为确保正确更新,需要在应用程序中调用函数InstallUpdateFiles()。