make use of modern nsis libs in installer script (#345)

This commit is contained in:
Cyano Hao 2024-03-30 00:00:56 +08:00 committed by GitHub
parent 7a3289b1d2
commit 1ea2846f2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 73 deletions

View File

@ -130,7 +130,7 @@ SectionEnd
####################################################################
# File association
SubSection "$(SectionAssocsName)" SectionAssocs
SectionGroup "$(SectionAssocsName)" SectionAssocs
Section "$(SectionAssocExtNameBegin) .dev $(SectionAssocExtNameEnd)"
SectionIn 1 3
@ -219,11 +219,11 @@ Section "$(SectionAssocExtNameBegin) .hpp $(SectionAssocExtNameEnd)"
${NotifyShell_AssocChanged}
SectionEnd
SubSectionEnd
SectionGroupEnd
####################################################################
# Shortcuts
SubSection "$(SectionShortcutsName)" SectionShortcuts
SectionGroup "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3
@ -241,7 +241,7 @@ Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd
SubSectionEnd
SectionGroupEnd
Section "$(SectionCompressName)" SectionCompress
DetailPrint "$(MessageCompressing)"
@ -328,77 +328,27 @@ Function un.onInit
!endif
FunctionEnd
;http://nsis.sourceforge.net/archive/viewpage.php?pageid=202
;After changing file associations, you can call this macro to refresh the shell immediatly.
;It calls the shell32 function SHChangeNotify. This will force windows to reload your changes from the registry.
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function un.DeleteDirIfEmpty
FindFirst $R0 $R1 "$0\*.*"
strcmp $R1 "." 0 NoDelete
FindNext $R0 $R1
strcmp $R1 ".." 0 NoDelete
ClearErrors
FindNext $R0 $R1
IfErrors 0 NoDelete
FindClose $R0
Sleep 1000
RMDir "$0"
NoDelete:
FindClose $R0
FunctionEnd
Function GetParent
Exch $R0
Push $R1
Push $R2
Push $R3
StrCpy $R1 0
StrLen $R2 $R0
loop:
IntOp $R1 $R1 + 1
IntCmp $R1 $R2 get 0 get
StrCpy $R3 $R0 1 -$R1
StrCmp $R3 "\" get
Goto loop
get:
StrCpy $R0 $R0 -$R1
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Var /GLOBAL uninstallString
Var /GLOBAL installLocation
Function UninstallExisting
ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done
Push $R0
Call GetParent
Pop $R1
ReadRegStr $uninstallString ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
${If} $uninstallString != ""
GetFullPathName $installLocation "$uninstallString\.." ; remove '\uninstall.exe'
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"$(MessageUninstallExisting)" \
IDOK uninst
"$(MessageUninstallExisting)" \
/SD IDNO \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
HideWindow
ClearErrors
ExecWait '"$R0" _?=$R1'
BringToFront
done:
uninst:
ClearErrors
HideWindow
ClearErrors
ExecWait '"$uninstallString" _?=$installLocation'
Delete "$uninstallString"
RMDir "$installLocation"
BringToFront
${EndIf}
FunctionEnd
####################################################################
@ -446,8 +396,7 @@ Section "Uninstall"
RMDir /r "$INSTDIR\mingw32"
RMDir /r "$INSTDIR\mingw64"
StrCpy $0 "$INSTDIR"
Call un.DeleteDirIfEmpty
RMDir "$INSTDIR"
; Remove registry keys
DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"