3

我有一个用 Delphi 编写的应用程序,它有几个版本,其中包含二进制文件和数据库 (MDB) 以及目录数据。

在产品生命周期中,修复/增强要么在数据库文件中,要么在某些二进制文件中。

版本保存在注册表中。

当新补丁可用时,用户可能有不同版本的程序。

现在用户有不同的版本如何在 Inno Setup 中实现以下场景:

  1. 如果用户有版本 A 阻止安装。
  2. 如果用户有版本 B 复制 db 和 file1、file2、file3。
  3. 如果用户有版本 C,只需更新 file1。

在 Inno 设置中实现这一点的正确方法是什么?

4

3 回答 3

2

我不确定这是否是正确的方法,但您可以使用 [code] 部分和 BeforeInstall Flags

像这样

[Files]
Source: "MYPROG.EXE"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall('{app}')
Source: "MYFILE.EXE"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall('{app}')
Source: "MYDB.MDB"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall('{app}')

[Code]

function MyBeforeInstall(InstallPath): Boolean;
begin
  Result:= FALSE;
    //Check if this file is ok to install
    MsgBox(CurrentFileName , mbInformation, MB_OK);
end;

然后使用 CurrentFileName 来确定文件是否可以安装,如果结果为假,我不确定它是否会退出安装程序,或者跳过单个文件。

您还可以使用 [Types]/[Components] 部分来确定将安装哪些文件,但我不知道是否有办法自动选择它。

于 2009-01-15T17:30:22.150 回答
2

Inno 默认会查看文件版本信息。因此,如果您的补丁只需要在补丁中的版本较新时更新文件,则什么也不做;Inno 已经这样做了。

另一方面,如果您的补丁需要替换具有相同版本的文件(或文件中没有版本信息),请使用replacesameversion标志。这会导致 Inno 比较文件的内容,如果不同则替换它。有关此标志的更多信息,请参阅文件的帮助。

于 2009-01-15T17:33:19.023 回答
0

您可以创建用于检查版本的函数。

有关详细信息,请参阅此网站( http://agiletracksoftware.com/blog.html?id=4 )

[Code]
; Each data file contains a single value and can be loaded after extracted.
; The filename and DestDir from the [Files] section must match the names
; and locations used here
function GetAppMajorVersion(param: String): String;
     var
          AppVersion: String;
     begin
          ExtractTemporaryFile('major.dat');
          LoadStringFromFile(ExpandConstant('{tmp}\major.dat'), AppVersion);
          Result := AppVersion;
     end;

function GetAppMinorVersion(param: String): String;
     var
          AppMinorVersion: String;
     begin
          ExtractTemporaryFile('minor.dat');
          LoadStringFromFile(ExpandConstant('{tmp}\minor.dat'), AppMinorVersion);
          Result := AppMinorVersion;
     end;

function GetAppCurrentVersion(param: String): String;
     var
          BuildVersion: String;
     begin
          ExtractTemporaryFile('build.dat');
          LoadStringFromFile(ExpandConstant('{tmp}\build.dat'), BuildVersion);
          Result := BuildVersion;
     end;

来自 AgileTrack 博客的代码摘录: 使用 Inno Setup 创建版本化安装程序

于 2009-01-23T16:30:38.510 回答