aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/installer/uninstall-single-arch.iss
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/installer/uninstall-single-arch.iss
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/installer/uninstall-single-arch.iss')
-rw-r--r--Src/external_dependencies/openmpt-trunk/installer/uninstall-single-arch.iss115
1 files changed, 115 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/installer/uninstall-single-arch.iss b/Src/external_dependencies/openmpt-trunk/installer/uninstall-single-arch.iss
new file mode 100644
index 00000000..86208da9
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/installer/uninstall-single-arch.iss
@@ -0,0 +1,115 @@
+
+
+
+[Code]
+
+function GetAppPath(AppId: String; IsWow64: Boolean): String;
+var
+ AppPath: String;
+begin
+ Result := '';
+ AppPath := '';
+ if IsWow64 then
+ begin
+ RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'Inno Setup: App Path', AppPath)
+ end
+ else
+ begin
+ RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'Inno Setup: App Path', AppPath)
+ end;
+ Result := AppPath;
+end;
+
+function GetUninstallCommand(AppId: String; IsWow64: Boolean): String;
+var
+ UninstallCommand: String;
+begin
+ Result := '';
+ UninstallCommand := '';
+ if IsWow64 then
+ begin
+ RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'UninstallString', UninstallCommand)
+ end
+ else
+ begin
+ RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'UninstallString', UninstallCommand)
+ end;
+ Result := UninstallCommand;
+end;
+
+function Uninstall(AppId: String; IsWow64: Boolean): Boolean;
+var
+ UninstallCommand: String;
+ ResultCode: Integer;
+begin
+ Result := False;
+ UninstallCommand := GetUninstallCommand(AppId, IsWow64);
+ if UninstallCommand <> '' then
+ begin
+ ResultCode := 0;
+ if Exec(RemoveQuotes(UninstallCommand), '/SILENT /NORESTART /SUPPRESSMSGBOXES', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
+ begin
+ Result := True;
+ end
+ else
+ begin
+ SuppressibleMsgBox('There was a problem removing the previous OpenMPT installation.', mbInformation, MB_OK, IDOK);
+ Result := False;
+ end;
+ end
+ else
+ begin
+ Result := True;
+ end;
+end;
+
+function UninstallSingleArch: Boolean;
+var
+ AppId_x86: String;
+ AppId_amd64: String;
+ Success: Boolean;
+begin
+ Success := True;
+ AppId_x86 := '{67903736-E9BB-4664-B148-F62BCAB4FA42}';
+ AppId_amd64 := '{9814C59D-8CBE-4C38-8A5F-7BF9B4FFDA6D}';
+ if IsWin64() then
+ begin
+ Success := Uninstall(AppId_amd64, False) and Success;
+ Success := Uninstall(AppId_x86, True) and Success;
+ end
+ else
+ begin
+ Success := Uninstall(AppId_x86, False) and Success;
+ end;
+ Result := Success;
+end;
+
+function GetPreviousSingleArchInstallPath: String;
+var
+ AppId_x86: String;
+ AppId_amd64: String;
+ AppPath: String;
+begin
+ AppPath := '';
+ AppId_x86 := '{67903736-E9BB-4664-B148-F62BCAB4FA42}';
+ AppId_amd64 := '{9814C59D-8CBE-4C38-8A5F-7BF9B4FFDA6D}';
+ if IsWin64() then
+ begin
+ if AppPath = '' then AppPath := GetAppPath(AppId_amd64, False);
+ if AppPath = '' then AppPath := GetAppPath(AppId_x86, True);
+ end
+ else
+ begin
+ if AppPath = '' then AppPath := GetAppPath(AppId_x86, False);
+ end;
+ Result := AppPath;
+end;
+
+function HasPreviousSingleArchInstallPath: Boolean;
+begin
+ Result := GetPreviousSingleArchInstallPath() <> '';
+end;
+
+
+
+