INNO setup:如何根据应用程序的不同版本实现文件更新

发布于 2024-07-11 17:52:59 字数 365 浏览 6 评论 0原文

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

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

版本保存在注册表中。

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

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

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

在 Inno 设置中实现此功能的正确方法是什么?

I have an application written in Delphi that has several versions that contain binaries and database (MDB) with catalog data.

During the product life cycle fixes/enhancements are either in database file or in some binary files.

Version are preserved in Registry.

Users might have different versions of the program when new patch is available.

Now users have different versions how to implement following scenario in Inno Setup:

  1. If user have version A prevent installation.
  2. If user have version B copy db over and file1, file2, file3.
  3. If user have version C just update file1.

What is the correct way to implement this in Inno setup?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫﹏色ふ单纯 2024-07-18 17:52:59

我不确定这是否是正确的方法,但您可以

像这样

[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;

使用 [code] 部分和 BeforeInstall 标志然后使用 CurrentFileName 确定文件是否可以安装,我不确定它是否会退出如果结果为 false,则安装程序,或者跳过单个文件。

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

I am not sure if it is the correct way to do it, but you can use the [code] section and the BeforeInstall Flags

like so

[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;

Then use CurrentFileName to determine if the file can be installed, I am not sure if it will just quit the installer if the result is false, or skip the individual file.

You can also use the [Types]/[Components] section to determine what files will be installed, but I don't know if there is a way to auto select that.

梦里南柯 2024-07-18 17:52:59

Inno默认会查看文件版本信息。 因此,如果您的补丁只需要在补丁中的版本较新时更新文件,则无需执行任何操作; 伊诺已经这么做了。

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

Inno will look at file version information by default. So if your patch just needs to only update a file when the version in the patch is newer, do nothing; Inno already behaves that way.

If, on the other hand, your patch needs to replace a file with the same version (or there is no version information in the file), use the replacesameversion flag. This causes Inno to compare the contents of the file, and replace it if it is different. See the help for Files for more information on this flag.

自此以后,行同陌路 2024-07-18 17:52:59

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

请参阅此网站了解更多详情
(http://agiletracksoftware.com/blog.html?id=4)< /strong>

[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 创建版本化安装程序

You can create functions for checking the version.

See this website for more details
(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;

Code extract from AgileTrack Blog:
Using Inno Setup to Create a Versioned Installer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文