Upgrades

From ISXKB

(Difference between revisions)
Jump to: navigation, search
(Minor changes)
(Added proviso)
Line 31: Line 31:
</pre>
</pre>
-
Nothing else is needed to do an upgrade installation as Inno handles the rest for you automatically.
+
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 ==
== See also ==

Revision as of 06:19, 23 June 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;
var
   sPrevPath: String;
begin
  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 <> '');
end;

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;
begin
  Result := False;
  if IsUpgrade() then
  begin
    if PageID = wpSelectDir then Result := True;
    if PageID = wpSelectProgramGroup then Result := True;
  end;
end;

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
Ads: