Eduardo
Eduardo

Reputation: 1837

How to read the VersionInfoVersion of my setup to compare with the existing version

In my installer, I have to check if the version being installed is lower than that of the application that is already installed on the computer.

If so, I have to close the installer without allowing the installation.

So, I have this code bellow:

if GetVersionNumbersString(ExpandConstant('{app}\bin\application.exe'), Version) then
begin
...
end;

This returns to me, the version number of application on computer. My question is:

How do I read the info in VersionInfoVersion of mySetup?

Upvotes: 4

Views: 1368

Answers (1)

Deanna
Deanna

Reputation: 24283

To correctly compare version numbers, you will need to do a numeric compare of each component of the version number.

You can use ISPP's GetFileVersion() to get the textual version number that you're installing at compile time and {#emit...} it into a PascalScript string variable, or use PascalScript's GetVersionNumbersString() at runtime and pass ExpandConstants('{srcexe}'). You can then use PascalScript's GetVersionNumbersString() function again to get the textual version of the application to be replaced.

When you have both of these in PascalScript string variables, you can use the CompareVersion() function to do the actual comparison.

Upvotes: 4

Related Questions