Upgrades

From ISXKB

(Difference between revisions)
Jump to: navigation, search
(Added ExpandConstant note)
Line 16: Line 16:
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.
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.
 +
 +
'''Warning:''' If your AppID consists of a GUID (so you have a leading {{) or if you use other constants within it, then you will also need to call ExpandConstant:
 +
  ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppID")}_is1')
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)
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)

Revision as of 02:51, 12 February 2009

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.

Warning: If your AppID consists of a GUID (so you have a leading {{) or if you use other constants within it, then you will also need to call ExpandConstant:

 ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppID")}_is1')

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: