1
0

uninstall-single-arch.iss 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. [Code]
  2. function GetAppPath(AppId: String; IsWow64: Boolean): String;
  3. var
  4. AppPath: String;
  5. begin
  6. Result := '';
  7. AppPath := '';
  8. if IsWow64 then
  9. begin
  10. RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'Inno Setup: App Path', AppPath)
  11. end
  12. else
  13. begin
  14. RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'Inno Setup: App Path', AppPath)
  15. end;
  16. Result := AppPath;
  17. end;
  18. function GetUninstallCommand(AppId: String; IsWow64: Boolean): String;
  19. var
  20. UninstallCommand: String;
  21. begin
  22. Result := '';
  23. UninstallCommand := '';
  24. if IsWow64 then
  25. begin
  26. RegQueryStringValue(HKLM, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'UninstallString', UninstallCommand)
  27. end
  28. else
  29. begin
  30. RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + AppId + '_is1', 'UninstallString', UninstallCommand)
  31. end;
  32. Result := UninstallCommand;
  33. end;
  34. function Uninstall(AppId: String; IsWow64: Boolean): Boolean;
  35. var
  36. UninstallCommand: String;
  37. ResultCode: Integer;
  38. begin
  39. Result := False;
  40. UninstallCommand := GetUninstallCommand(AppId, IsWow64);
  41. if UninstallCommand <> '' then
  42. begin
  43. ResultCode := 0;
  44. if Exec(RemoveQuotes(UninstallCommand), '/SILENT /NORESTART /SUPPRESSMSGBOXES', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
  45. begin
  46. Result := True;
  47. end
  48. else
  49. begin
  50. SuppressibleMsgBox('There was a problem removing the previous OpenMPT installation.', mbInformation, MB_OK, IDOK);
  51. Result := False;
  52. end;
  53. end
  54. else
  55. begin
  56. Result := True;
  57. end;
  58. end;
  59. function UninstallSingleArch: Boolean;
  60. var
  61. AppId_x86: String;
  62. AppId_amd64: String;
  63. Success: Boolean;
  64. begin
  65. Success := True;
  66. AppId_x86 := '{67903736-E9BB-4664-B148-F62BCAB4FA42}';
  67. AppId_amd64 := '{9814C59D-8CBE-4C38-8A5F-7BF9B4FFDA6D}';
  68. if IsWin64() then
  69. begin
  70. Success := Uninstall(AppId_amd64, False) and Success;
  71. Success := Uninstall(AppId_x86, True) and Success;
  72. end
  73. else
  74. begin
  75. Success := Uninstall(AppId_x86, False) and Success;
  76. end;
  77. Result := Success;
  78. end;
  79. function GetPreviousSingleArchInstallPath: String;
  80. var
  81. AppId_x86: String;
  82. AppId_amd64: String;
  83. AppPath: String;
  84. begin
  85. AppPath := '';
  86. AppId_x86 := '{67903736-E9BB-4664-B148-F62BCAB4FA42}';
  87. AppId_amd64 := '{9814C59D-8CBE-4C38-8A5F-7BF9B4FFDA6D}';
  88. if IsWin64() then
  89. begin
  90. if AppPath = '' then AppPath := GetAppPath(AppId_amd64, False);
  91. if AppPath = '' then AppPath := GetAppPath(AppId_x86, True);
  92. end
  93. else
  94. begin
  95. if AppPath = '' then AppPath := GetAppPath(AppId_x86, False);
  96. end;
  97. Result := AppPath;
  98. end;
  99. function HasPreviousSingleArchInstallPath: Boolean;
  100. begin
  101. Result := GetPreviousSingleArchInstallPath() <> '';
  102. end;