Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INNO Setup: How to implement file update based on different versions of the application

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?

like image 324
Irfan Mulic Avatar asked Nov 14 '25 09:11

Irfan Mulic


2 Answers

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.

like image 86
Re0sless Avatar answered Nov 17 '25 06:11

Re0sless


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.

like image 30
Craig Stuntz Avatar answered Nov 17 '25 06:11

Craig Stuntz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!