(Difference between revisions)
Jump to: navigation, search
(Added proviso)
Line 37: Line 37:
*[[Detect if an application is running]]
*[[Detect if an application is running]]
*[[Only one installer instance]]
*[[Only one installer instance]]
*[[Checking application prerequisites]]

Revision as of 22:17, 1 December 2008

Inno Setup currently has no built in function to detect if you are installing fresh, or upgrading an existing install with the same AppID. Until then, you will need to make use of a small function that looks up the previous installation directory and returns TRUE if it's an upgrade or FALSE if it's not:

function IsUpgrade(): Boolean;
   sPrevPath: String;
  sPrevPath := '';
  if not RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppID")}_is1', 'UninstallString', sPrevpath) then
    RegQueryStringValue(HKCU, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppID")}_is1', 'UninstallString', sPrevpath);
  Result := (sPrevPath <> '');

This first checks the uninstall key in HKEY_LOCAL_MACHINE, and if that fails, checks HKEY_CURRENT_USER.

Bear in mind that this snippet uses ISPP, but if you do not have this available, replace {#emit SetupSetting("AppID")} with the AppID used by your setup.

You can then use the return value of this function to hide the install directory and program group selection pages. This stops the user from installing the same app into multiple locations and generally making a mess... :o)

function ShouldSkipPage(PageID: Integer): Boolean;
  Result := False;
  if IsUpgrade() then
    if PageID = wpSelectDir then Result := True;
    if PageID = wpSelectProgramGroup then Result := True;

Nothing else is needed to do an upgrade installation as Inno handles the rest for you automatically (provided you have specified appropriate Flags on your install entries).

See also

Personal tools