Added UnpinShortcut and NotifyShell_AssocChanged macros

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7183 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2020-05-21 00:44:39 +00:00
parent ea50284c18
commit 3c47165946
6 changed files with 63 additions and 16 deletions

View file

@ -16,6 +16,8 @@ Released on ? ?th, 2020
\b Added \R{getknownfolderpath}{GetKnownFolderPath}
\b Added UnpinShortcut macro (Integration.nsh)
\S2{} Minor Changes
\b Added \R{ifshellvarcontextall}{IfShellVarContextAll} and \R{ifrtllanguage}{IfRtlLanguage}

View file

@ -22,6 +22,7 @@ InstallDirRegKey HKCU "${REGPATH_UNINSTSUBKEY}" "UninstallString"
!include LogicLib.nsh
!include WinCore.nsh
!include Integration.nsh
Page Directory
@ -103,7 +104,7 @@ Section -ShellAssoc
WriteRegStr ShCtx "Software\RegisteredApplications" "Nullsoft Test App" "Software\Classes\Applications\${ASSOC_APPEXE}\Capabilities"
!endif
System::Call 'SHELL32::SHChangeNotify(i0x08000000, i0, p0, p0)' ; Notify the shell with SHCNE_ASSOCCHANGED
${NotifyShell_AssocChanged}
SectionEnd
@ -153,14 +154,15 @@ Section -un.ShellAssoc
;DeleteRegKey HKCU "Software\Microsoft\Windows\Roaming\OpenWith\FileExts\${ASSOC_EXT}"
;DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\${ASSOC_EXT}"
System::Call 'SHELL32::SHChangeNotify(i0x08000000, i0, p0, p0)' ; Notify the shell with SHCNE_ASSOCCHANGED
${NotifyShell_AssocChanged}
SectionEnd
Section -Uninstall
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
Delete "$InstDir\MyApp.exe"
Delete "$InstDir\Uninst.exe"
RMDir "$InstDir"
DeleteRegKey HKCU "${REGPATH_UNINSTSUBKEY}"
Delete "$SMPrograms\${NAME}.lnk"
SectionEnd

View file

@ -21,14 +21,15 @@ RequestExecutionLevel Admin ; Request admin rights on WinVista+ (when UAC is tur
InstallDir "$ProgramFiles\$(^Name)"
InstallDirRegKey HKLM "${REGPATH_UNINSTSUBKEY}" "UninstallString"
!include LogicLib.nsh
!include Integration.nsh
Page Directory
Page InstFiles
Uninstpage UninstConfirm
Uninstpage InstFiles
!include LogicLib.nsh
!macro EnsureAdminRights
UserInfo::GetAccountType
Pop $0
@ -70,10 +71,11 @@ SectionEnd
Section -Uninstall
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
Delete "$InstDir\MyApp.exe"
Delete "$InstDir\Uninst.exe"
RMDir "$InstDir"
DeleteRegKey HKLM "${REGPATH_UNINSTSUBKEY}"
Delete "$SMPrograms\${NAME}.lnk"
SectionEnd

View file

@ -49,12 +49,7 @@ RequestExecutionLevel admin
!include "Memento.nsh"
!include "WordFunc.nsh"
!include "Util.nsh"
;--------------------------------
;Definitions
!define SHCNE_ASSOCCHANGED 0x8000000
!define SHCNF_IDLIST 0
!include "Integration.nsh"
;--------------------------------
;Configuration
@ -213,6 +208,7 @@ ${MementoSection} "NSIS Core Files (required)" SecCore
File ..\Include\MultiUser.nsh
File ..\Include\VB6RunTime.nsh
File ..\Include\Util.nsh
File ..\Include\Integration.nsh
File ..\Include\WinCore.nsh
SetOutPath $INSTDIR\Include\Win
@ -296,7 +292,7 @@ ${MementoSection} "NSIS Core Files (required)" SecCore
WriteRegStr HKCR "NSIS.Header\shell\open\command" "" 'notepad.exe "%1"'
${EndIf}
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, p0, p0)'
${NotifyShell_AssocChanged}
${MementoSectionEnd}
@ -1071,7 +1067,7 @@ Section Uninstall
!insertmacro AssocDeleteFileExtAndProgId HKLM ".nsi" "NSIS.Script"
!insertmacro AssocDeleteFileExtAndProgId HKLM ".nsh" "NSIS.Header"
System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, p0, p0)'
${NotifyShell_AssocChanged}
DeleteRegKey HKLM "${REG_UNINST_KEY}"
DeleteRegKey HKLM "Software\NSIS"

44
Include/Integration.nsh Normal file
View file

@ -0,0 +1,44 @@
!verbose push 3
!ifndef INTEGRATION_INCLUDED
!define INTEGRATION_INCLUDED 1
!include "Util.nsh"
!define NotifyShell_AssocChanged `System::Call 'SHELL32::SHChangeNotify(i0x8000000,i0,p0,p0)'` ; Notify the shell with SHCNE_ASSOCCHANGED
!define UnpinShortcut "!insertmacro UnpinShortcut "
!macro UnpinShortcut lnkpath
Push "${lnkpath}"
${CallArtificialFunction} UnpinShortcut_Implementation
!macroend
!macro UnpinShortcut_Implementation
!include "LogicLib.nsh"
!include "Win\COM.nsh"
Exch $0
Push $1
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} ${IID_IStartMenuPinnedList} r1 ""
${If} $1 P<> 0
System::Call 'SHELL32::SHCreateItemFromParsingName(wr0,p0,g"${IID_IShellItem}",*p0r0)'
${If} $0 P<> 0
${IStartMenuPinnedList::RemoveFromList} $1 '(r0)'
${IUnknown::Release} $0 ""
${EndIf}
${IUnknown::Release} $1 ""
!ifdef NSIS_IX86 | NSIS_AMD64
${Else}
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} "{ec35e37a-6579-4f3c-93cd-6e62c4ef7636}" r1 ""
${If} $1 P<> 0
ExecShellWait /INVOKEIDLIST "unpin" $0 ; WinXP
${IUnknown::Release} $1 ""
${EndIf}
!endif
${EndIf}
Pop $1
Pop $0
!macroend
!endif #!INCLUDED
!verbose pop

View file

@ -1,6 +1,7 @@
includes = Split("""
Colors.nsh
FileFunc.nsh
Integration.nsh
LangFile.nsh
Library.nsh
LogicLib.nsh