diff options
Diffstat (limited to 'installer_scripts/template.iss')
| -rwxr-xr-x | installer_scripts/template.iss | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/installer_scripts/template.iss b/installer_scripts/template.iss index aab1e912..a2654c36 100755 --- a/installer_scripts/template.iss +++ b/installer_scripts/template.iss @@ -32,6 +32,7 @@ VersionInfoCompany={#URL} VersionInfoCopyright=Copyright (C) {#COPYRIGHT}
VersionInfoDescription=An open-source machine embroidery design platform based on Inkscape.
VersionInfoTextVersion={#VERSION}
+VersionInfoVersion=1.0
WizardStyle=modern
ShowLanguageDialog=no
@@ -68,17 +69,62 @@ Name: "English"; Description: "English"; Source: "{#PATHTODIST}\inkstitch\*"; DestDir: "{app}\inkstitch\inkstitch"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Code]
+// SOURCE: https://stackoverflow.com/questions/2000296/inno-setup-how-to-automatically-uninstall-previous-installed-version
+{ ///////////////////////////////////////////////////////////////////// }
+function GetUninstallString(): String;
+var
+ sUnInstPath: String;
+ sUnInstallString: String;
+begin
+ sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
+ sUnInstallString := '';
+ if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
+ RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
+ Result := sUnInstallString;
+end;
+
+
+{ ///////////////////////////////////////////////////////////////////// }
+function IsUpgrade(): Boolean;
+begin
+ Result := (GetUninstallString() <> '');
+end;
+
-function InitializeSetup(): Boolean;
+{ ///////////////////////////////////////////////////////////////////// }
+function UnInstallOldVersion(): Integer;
+var
+ sUnInstallString: String;
+ iResultCode: Integer;
begin
- Result := True;
- if RegKeyExists(HKEY_LOCAL_MACHINE,
- 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') or
- RegKeyExists(HKEY_CURRENT_USER,
- 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1') then
+{ Return Values: }
+{ 1 - uninstall string is empty }
+{ 2 - error executing the UnInstallString }
+{ 3 - successfully executed the UnInstallString }
+
+ { default return value }
+ Result := 0;
+
+ { get the uninstall string of the old app }
+ sUnInstallString := GetUninstallString();
+ if sUnInstallString <> '' then begin
+ sUnInstallString := RemoveQuotes(sUnInstallString);
+ if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
+ Result := 3
+ else
+ Result := 2;
+ end else
+ Result := 1;
+end;
+
+{ ///////////////////////////////////////////////////////////////////// }
+procedure CurStepChanged(CurStep: TSetupStep);
+begin
+ if (CurStep=ssInstall) then
begin
- MsgBox('The application is installed already.', mbInformation, MB_OK);
- Result := False;
+ if (IsUpgrade()) then
+ begin
+ UnInstallOldVersion();
+ end;
end;
end;
-
|
