Versions in InnoSetup

Using the InnoSetup preprocessor, you can automatically give the setup file the same version as the program file you're packaging with InnoSetup. Predefined functions are

  • GetFileVersion, e.g. 3.3.3117.29914
  • GetFileProductVersion, e.g. 3.3.0.0

Additionally, you can add the following macro to your InnoSetup script found here. It supports only single digit version numbers though.

; ; Inno Setup Preprocessor macro to simplify the version string. ; ; The following situations are covered: ; ; (1) 1.2.4.3 -> 1.2.4 ; (2) 1.2.4.0 -> 1.2.4 ; (3) 1.2.0.0 -> 1.2 ; (4) 1.0.0.0 -> 1.0 ; (5) 1.0.0.2 -> 1.0 ; (6) 1.3.0.1 -> 1.3 ; #define SimpleVersion(str S) \ Local[0] = Pos (".0.0.", S), \ /* (4) and (5) */ \ (Local[0] > 0) ? Copy (S, 1, 3) : \ ( \ Local[0] = Pos (".0.0", S), \ /* (3) */ \ (Local[0] > 0) ? Copy (S, 1, 3) : \ ( \ Local[0] = Pos (".0", S), \ /* (2) */ \ (Local[0] > 5) ? Copy (S, 1, Local[0] - 1) : \ ( \ Local[0] = Pos (".0.", S), \ /* (6) */ \ (Local[0] > 0) ? Copy (S, 1, 3) : \ ( \ Copy (S, 1, 5) \ ) \ ) \ ) \ );

and then use that macro to define the version

#define MyAppVersion   SimpleVersion(GetFileVersion("app.exe"))

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5