views:

3189

answers:

3

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?

+2  A: 

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.

Re0sless
+2  A: 

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.

Craig Stuntz
A: 

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

golimpio