correct uninstall string in registry (#347)
This commit is contained in:
parent
9a99781549
commit
89423870dd
|
@ -323,16 +323,16 @@ bool isGreenEdition()
|
|||
#ifdef Q_OS_WIN
|
||||
if (!gIsGreenEditionInited) {
|
||||
QString appPath = QApplication::instance()->applicationDirPath();
|
||||
appPath = excludeTrailingPathDelimiter(appPath);
|
||||
appPath = excludeTrailingPathDelimiter(localizePath(appPath));
|
||||
QString keyString = R"(Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++)";
|
||||
QString systemInstallPath;
|
||||
readRegistry(HKEY_LOCAL_MACHINE, keyString, "UninstallString", systemInstallPath);
|
||||
readRegistry(HKEY_LOCAL_MACHINE, keyString, "InstallLocation", systemInstallPath);
|
||||
if (!systemInstallPath.isEmpty())
|
||||
systemInstallPath = excludeTrailingPathDelimiter(extractFileDir(systemInstallPath));
|
||||
systemInstallPath = excludeTrailingPathDelimiter(systemInstallPath);
|
||||
QString userInstallPath;
|
||||
readRegistry(HKEY_CURRENT_USER, keyString, "UninstallString", userInstallPath);
|
||||
readRegistry(HKEY_CURRENT_USER, keyString, "InstallLocation", userInstallPath);
|
||||
if (!userInstallPath.isEmpty())
|
||||
userInstallPath = excludeTrailingPathDelimiter(extractFileDir(userInstallPath));
|
||||
userInstallPath = excludeTrailingPathDelimiter(userInstallPath);
|
||||
gIsGreenEdition = appPath.compare(systemInstallPath, Qt::CaseInsensitive) != 0 &&
|
||||
appPath.compare(userInstallPath, Qt::CaseInsensitive) != 0;
|
||||
gIsGreenEditionInited = true;
|
||||
|
|
|
@ -10,7 +10,8 @@ LangString MessageSectionShortcuts 1033 "Create shortcuts to Red Panda
|
|||
LangString MessageSectionCompress 1033 "Compress the Red Panda C++ installation directory (requires Windows 10 or later)"
|
||||
LangString MessageSectionConfig 1033 "Remove all leftover configuration files from previous installs"
|
||||
LangString MessageUninstallText 1033 "This program will uninstall Red Panda C++, continue?"
|
||||
LangString MessageUninstallExisting 1033 " Red Panda C++ is already installed. $\n$\nClick OK to remove the previous version or Cancel to cancel the installation."
|
||||
LangString MessageUninstallV2 1033 " Red Panda C++ is already installed. $\n$\nClick OK to remove the previous version or Cancel to cancel the installation."
|
||||
LangString MessageUninstallingExisting 1033 "Removing the previous version..."
|
||||
LangString MessageCompressing 1033 "Compressing the Red Panda C++ installation directory..."
|
||||
LangString MessageRemoveConfig 1033 "Do you want to remove all the remaining configuration files?"
|
||||
LangString SectionMainName 1033 "Program files (required)"
|
||||
|
@ -44,7 +45,8 @@ LangString MessageSectionShortcuts 2052 "开始菜单和快捷方式"
|
|||
LangString MessageSectionCompress 2052 "压缩小熊猫 C++ 安装目录(需要 Windows 10 或更高版本)"
|
||||
LangString MessageSectionConfig 2052 "删除之前安装遗留的所有配置文件"
|
||||
LangString MessageUninstallText 2052 "将要删除小熊猫C++, 是否继续?"
|
||||
LangString MessageUninstallExisting 2052 "本机上已经安装了旧版本小熊猫C++. $\n$\n点击'确定'以将其删除并继续,或者'取消'中止安装。"
|
||||
LangString MessageUninstallV2 2052 "本机上已经安装了旧版本小熊猫C++. $\n$\n点击'确定'以将其删除并继续,或者'取消'中止安装。"
|
||||
LangString MessageUninstallingExisting 2052 "正在删除旧版本..."
|
||||
LangString MessageCompressing 2052 "正在压缩小熊猫 C++ 安装目录..."
|
||||
LangString MessageRemoveConfig 2052 "你想要删除所有的配置文件吗?"
|
||||
LangString SectionMainName 2052 "程序文件 (必须)"
|
||||
|
|
|
@ -4,10 +4,14 @@ SetFont "Segoe UI" 11
|
|||
Unicode True
|
||||
!define DISPLAY_NAME "Red Panda C++ ${APP_VERSION} (${ARCH})"
|
||||
|
||||
!define REGISTRY_PROGRAM_ID "RedPanda-C++"
|
||||
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGISTRY_PROGRAM_ID}"
|
||||
|
||||
!include "Integration.nsh"
|
||||
!include "LogicLib.nsh"
|
||||
!include "MUI2.nsh"
|
||||
!include "WinVer.nsh"
|
||||
!include "WordFunc.nsh"
|
||||
!include "x64.nsh"
|
||||
|
||||
!include "lang.nsh"
|
||||
|
@ -77,6 +81,13 @@ InstType "Safe";3
|
|||
!insertmacro MUI_LANGUAGE "English"
|
||||
!insertmacro MUI_LANGUAGE "SimpChinese"
|
||||
|
||||
####################################################################
|
||||
# Silently uninstall previous version
|
||||
|
||||
Section "" SecUninstallPrevious
|
||||
!insertmacro CheckPreviousInstaller
|
||||
SectionEnd
|
||||
|
||||
####################################################################
|
||||
# Files, by option section
|
||||
|
||||
|
@ -87,11 +98,13 @@ Section "$(SectionMainName)" SectionMain
|
|||
|
||||
; Allways create an uninstaller
|
||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
|
||||
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
|
||||
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${APP_VERSION}"
|
||||
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
|
||||
WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
|
||||
WriteRegStr ShCtx "${UNINSTKEY}" "DisplayName" "Redpanda-C++"
|
||||
WriteRegStr ShCtx "${UNINSTKEY}" "InstallLocation" "$INSTDIR"
|
||||
WriteRegStr ShCtx "${UNINSTKEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegStr ShCtx "${UNINSTKEY}" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S'
|
||||
WriteRegStr ShCtx "${UNINSTKEY}" "DisplayVersion" "${APP_VERSION}"
|
||||
WriteRegStr ShCtx "${UNINSTKEY}" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
|
||||
WriteRegStr ShCtx "${UNINSTKEY}" "Publisher" "Roy Qu(royqh1979@gmail.com)"
|
||||
|
||||
|
||||
; Write required files
|
||||
|
@ -300,18 +313,7 @@ FunctionEnd
|
|||
Function myGuiInit
|
||||
!insertmacro CheckOsArch
|
||||
!insertmacro CheckOsBuild
|
||||
|
||||
; uninstall existing
|
||||
SetRegView 32
|
||||
Call UninstallExisting
|
||||
SetRegView 64
|
||||
Call UninstallExisting
|
||||
|
||||
!if "${ARCH}" == "x86"
|
||||
SetRegView 32
|
||||
!else
|
||||
SetRegView 64
|
||||
!endif
|
||||
!insertmacro CheckV2Installer
|
||||
|
||||
!insertmacro SectionAction_CheckMingw64
|
||||
!insertmacro SectionAction_CheckCompress
|
||||
|
@ -330,24 +332,42 @@ FunctionEnd
|
|||
|
||||
Var /GLOBAL uninstallString
|
||||
Var /GLOBAL installLocation
|
||||
Var /GLOBAL oldVersion
|
||||
Var /GLOBAL versionCompareResult
|
||||
|
||||
Function UninstallExisting
|
||||
ReadRegStr $uninstallString ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
|
||||
ReadRegStr $uninstallString ShCtx "${UNINSTKEY}" "UninstallString"
|
||||
${If} $uninstallString != ""
|
||||
GetFullPathName $installLocation "$uninstallString\.." ; remove '\uninstall.exe'
|
||||
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
|
||||
"$(MessageUninstallExisting)" \
|
||||
/SD IDNO \
|
||||
IDOK uninst
|
||||
Abort
|
||||
uninst:
|
||||
ClearErrors
|
||||
HideWindow
|
||||
ClearErrors
|
||||
ExecWait '"$uninstallString" _?=$installLocation'
|
||||
ReadRegStr $installLocation ShCtx "${UNINSTKEY}" "InstallLocation"
|
||||
DetailPrint "$(MessageUninstallingExisting)"
|
||||
; uninstallString already quoted; NSIS requires installLocation unquoted
|
||||
ExecWait '$uninstallString /S _?=$installLocation'
|
||||
Delete "$uninstallString"
|
||||
RMDir "$installLocation"
|
||||
BringToFront
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function UninstallV2
|
||||
ReadRegStr $oldVersion HKLM "${UNINSTKEY}" "DisplayVersion"
|
||||
${If} $oldVersion != ""
|
||||
${VersionCompare} "3.0" "$oldVersion" $versionCompareResult
|
||||
${If} "$versionCompareResult" == 1 ; 1st version is greater
|
||||
ReadRegStr $uninstallString HKLM "${UNINSTKEY}" "UninstallString"
|
||||
GetFullPathName $installLocation "$uninstallString\.." ; remove '\uninstall.exe'
|
||||
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
|
||||
"$(MessageUninstallV2)" \
|
||||
/SD IDNO \
|
||||
IDOK uninst
|
||||
Abort
|
||||
uninst:
|
||||
ClearErrors
|
||||
HideWindow
|
||||
ClearErrors
|
||||
ExecWait '"$uninstallString" _?=$installLocation'
|
||||
Delete "$uninstallString"
|
||||
RMDir "$installLocation"
|
||||
BringToFront
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
|
@ -399,7 +419,7 @@ Section "Uninstall"
|
|||
RMDir "$INSTDIR"
|
||||
|
||||
; Remove registry keys
|
||||
DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
|
||||
DeleteRegKey ShCtx "${UNINSTKEY}"
|
||||
DeleteRegKey ShCtx "Software\RedPanda-C++"
|
||||
|
||||
MessageBox MB_YESNO "$(MessageRemoveConfig)" /SD IDNO IDNO SkipRemoveConfig
|
||||
|
|
|
@ -45,6 +45,30 @@ Var /GLOBAL sectionDepTemp
|
|||
${EndIf}
|
||||
!macroend
|
||||
|
||||
!macro CheckV2Installer
|
||||
SetRegView 32
|
||||
Call UninstallV2
|
||||
SetRegView 64
|
||||
Call UninstallV2
|
||||
!if "${ARCH}" == "x86"
|
||||
SetRegView 32
|
||||
!else
|
||||
SetRegView 64
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!macro CheckPreviousInstaller
|
||||
SetRegView 32
|
||||
Call UninstallExisting
|
||||
SetRegView 64
|
||||
Call UninstallExisting
|
||||
!if "${ARCH}" == "x86"
|
||||
SetRegView 32
|
||||
!else
|
||||
SetRegView 64
|
||||
!endif
|
||||
!macroend
|
||||
|
||||
!macro DisableSection section
|
||||
SectionGetFlags ${section} $sectionDepFlag
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
APP_VERSION="2.27"
|
||||
APP_VERSION="3.0"
|
||||
APP_VERSION_SUFFIX="rc1"
|
||||
|
|
Loading…
Reference in New Issue