Product Version Numbers in InstallScript and InstallScript Object Projects

InstallShield 2016

Project • This information applies to the following project types:

InstallScript
InstallScript Object

By default, InstallScript projects use version numbers in packed DWORD format—that is, as a four-byte value whose first byte is the major version, second byte is the minor version, and last two bytes are the build number. Packed DWORDS are entered and displayed in the format major.minor.build; for example, 1.2.3 or 255.255.65535. Packed DWORD version numbers are assumed in the default script code for registering the version number of the product that is being installed, and for comparing that version number to that of the already installed product during an update installation.

If any of these version numbers are not in packed DWORD format, you must modify the script code as discussed in the following sections.

Version Number of the Already Installed Product

The default OnSetUpdateMode event handler function code compares the version number of the product that is being installed, and the version numbers to which the update can be applied (as specified in the Release property sheet), to the system variable IFX_INSTALLED_VERSION. The installation automatically attempts to initialize the value of this system variable to the string equivalent of the data in the Version value under the application uninstallation registry key. If that value does not exist, or its data is not a packed DWORD, then the value of IFX_INSTALLED_VERSION is a null string (""), in which case the default OnSetUpdateMode code displays an error message and aborts the installation. One solution is to insert code that checks the version information on the system and sets IFX_INSTALLED_VERSION equal to an appropriate packed DWORD value. For example, if previous installations stored a version string in the MyVersion value under HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\MyProduct, you could insert code like the following:

if (IFX_INSTALLED_VERSION="") then

    /* Get the registered version information. */

    RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );

    RegDBGetKeyValueEx( "Software\\MyCompany\\MyProduct",

        "MyVersion", REGDB_STRING, szVersionString, nSize );

 

    /* Assign a value to IFX_INSTALLED_VERSION. */

    switch (szVersionString)

        /* A registered version string of "A" corresponds to an existing version number of 1.0.0. */

        case "A":

            IFX_INSTALLED_VERSION = "1.0.0";

        /* A registered version string of "B" corresponds to an existing version number of 1.1.0. */

        case "B":

            IFX_INSTALLED_VERSION = "1.1.0";

        /* An absent version string corresponds to an existing version number of 0.0.0. */

        default:

            IFX_INSTALLED_VERSION = "0.0.0";

    endswitch;

endif;

Version Number of the Product that Is Being Installed

The default OnMoveData event handler function code calls RegDBSetVersion to take the product version number that you entered in the General Information view and enter it in the target system’s registry. RegDBSetVersion assumes that the product version is in packed DWORD format. If you want to register a product version that is not in packed DWORD format, you must replace OnMoveData’s call of RegDBSetVersion with code like the following:

/* The setup automatically initializes the value of the system variable

IFX_PRODUCT_VERSION to the product version that you entered in the

Product Version setting in the General Information view. */

RegDBSetItem(REGDB_UNINSTALL_VERSION, IFX_PRODUCT_VERSION );

RegDBSetItem(REGDB_UNINSTALL_DISPLAY_VERSION, IFX_PRODUCT_VERSION );

RegDBSetItem must be called after MaintenanceStart.

See Also