From a0031159cd15e2798996f53c05d98b10ec69ead0 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 18 Feb 2023 17:43:24 +0100 Subject: [PATCH] Add new explorer context menu entry "Edit with Notepad++" for W11 Windows 11 has its new interface for its explorer context menu. It makes the old "Edit with Notepad++" command hardly accessible. This commit improves the accessibility and also fix issue of run as an administrator (Properties set in Compatibility) in the new context menu command. It fixes also the context menu command issue under ARM64 architecture (fixed only under Windows 11). The localization of "Edit with Notepad++" is also possible in this commit. Note that if the command place of "Edit with Notepad++" context menu command is taken by other application ("\HKEY_CLASSES_ROOT*\shell\pintohome"), the new context menu "Edit with Notepad++" won't be installed. User should install it him/herself. Fix #10320, fix #10565, fix #4368, fix #8786, fix #10320, fix #10640, fix #10856, fix #10653, fix #7747, fix #6169, fix #92, close #13170 --- .../explorerContextMenuEntryLocal.ini | Bin 0 -> 8088 bytes PowerEditor/installer/nppSetup.nsi | 34 ++++++++ .../nsisInclude/mainSectionFuncs.nsh | 3 +- .../installer/nsisInclude/uninstall.nsh | 17 ++++ PowerEditor/installer/nsisInclude/winVer.nsh | 76 ++++++++++-------- 5 files changed, 95 insertions(+), 35 deletions(-) create mode 100644 PowerEditor/installer/nativeLang/explorerContextMenuEntryLocal.ini diff --git a/PowerEditor/installer/nativeLang/explorerContextMenuEntryLocal.ini b/PowerEditor/installer/nativeLang/explorerContextMenuEntryLocal.ini new file mode 100644 index 0000000000000000000000000000000000000000..b301957065127aafe903352087e30bce3be3bb5a GIT binary patch literal 8088 zcmc(k+iFu$5QgVk@Etb2QSn4oyimLm6$B3#>Xk^@O_MYx-HCfAwiSE^pHlEC)c>2w zGS!AsTO5(P4{Pl;^Z)bDtV4c$zi*Yjwq5J%+P4Fn*~F&S>b}*Rp6(l)d&^wUd%A0E zp}P%xY&$kmTV?xx-PPR-^{4mDYPDX~zYV?Z>8a6mTP>B^TYv6ksrKGGdizmh)Vhw; zv(wvJtrPXfi@E$`gt1z9nl9gs{CS{n=y}5~+64noxfWaleZgo`_q4I0`poo%t+|iU z$--2)Ci1%YS*v&LOjK$cxJ@jNWebGi*E&Qa^#||1uC4lGXK449eiiRF<#A;O z)pbo{Y|Bef!6R4rL1m2JXiQW~#E*}@^-H^3Yqh(=a@(;ya?dZhmE$@lE7oVgtDk-=i9t>3J$tks||f&>V?;iDyKOQOOU_MY1aR@Yj*9NUQ^_XCs8@_rn1ivQqX<1jJi+-^E$AB^gR11)JI~Tm z+fLTUgHzT(?1jyNFkqLAJD$|}`#3N&mMAkbiHa7p5d7va%bJ1tY2ou?=sCyow(QoLZ&~TEPHJpRoc}Lxc6`1) ze+@fr=C-oOToA}}7>C{5xq($xXgW{PJ!y*h)l9_qzGKax% zPk(uN!Wqic_k6h#Eq3d)n6ftoV_rl#MVhGYWv@-B3_FTy>=HB8go3x1Jm+b+r|K}3 zRnDFAtb((%4~j7-#c{U!Z_j!-?dB9Ub}yM&IpJx2e#_&R)ir1jlh~aok_W=MC!Czz zx4vS@s}{9Ruh_$kg&CH+B-{(_*ics1ijcVWWG^aIri!1*@_hNbP}T_#TIzh>$;=#T z|4^38*-lP<;{1x=7jjn;oY2SqG=3G#!5TZoK$~NcQ&^DZ?xXk>wXdj_U%i+Ka`3We WoJdhwCrM+k`MGQUkyrc-j6VUj##H41 literal 0 HcmV?d00001 diff --git a/PowerEditor/installer/nppSetup.nsi b/PowerEditor/installer/nppSetup.nsi index 1a7148a1e..c3089d2cc 100644 --- a/PowerEditor/installer/nppSetup.nsi +++ b/PowerEditor/installer/nppSetup.nsi @@ -261,7 +261,39 @@ FunctionEnd !include "nsisInclude\themes.nsh" +!include "StrFunc.nsh" +${Using:StrFunc} StrStr + +Var muiVerbStr +Var nppSubStrRes +Var editWithNppLocalStr + ${MementoSection} "Context Menu Entry" explorerContextMenu + + ${If} $WinVer == "11" + ReadRegStr $muiVerbStr HKLM "SOFTWARE\Classes\*\shell\pintohome" MUIVerb + + ${StrStr} $nppSubStrRes $muiVerbStr "Notepad++" + ;MessageBox MB_OK "entry value: $muiVerbStr" + ;MessageBox MB_OK "result: $nppSubStrRes" + + ; Make sure there's no entry before creating it, so we won't override other application if present + ${If} $muiVerbStr == "" + ${OrIf} $nppSubStrRes != "" ; it contains "Notepad++" + + ReadINIStr $editWithNppLocalStr "$PLUGINSDIR\nppLocalization\explorerContextMenuEntryLocal.ini" $(langFileName) "Edit_with_Notepad++" + ${If} $editWithNppLocalStr == "" + StrCpy $editWithNppLocalStr "Edit with Notepad++" + MessageBox MB_OK "translation: $editWithNppLocalStr" + ${EndIf} + + WriteRegStr HKLM "SOFTWARE\Classes\*\shell\pintohome" 'MUIVerb' $editWithNppLocalStr + WriteRegStr HKLM "SOFTWARE\Classes\*\shell\pintohome\command" "" '"$INSTDIR\notepad++.exe" "%1"' + + ${EndIf} + + ${EndIf} + SetOverwrite try SetOutPath "$INSTDIR\" @@ -281,6 +313,8 @@ ${MementoSection} "Context Menu Entry" explorerContextMenu ${EndIf} !endif Exec 'regsvr32 /s "$INSTDIR\NppShell_06.dll"' + + ${MementoSectionEnd} ${MementoSectionDone} diff --git a/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh b/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh index 98fcdde05..1ad989639 100644 --- a/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh +++ b/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh @@ -115,7 +115,7 @@ Function copyCommonFiles SetOutPath "$INSTDIR\localization\" File ".\nativeLang\english.xml" - ; Copy all the language files to the temp directory + ; Copy all the Notepad++ localization files to the temp directory ; than make them installed via option SetOutPath "$PLUGINSDIR\nppLocalization\" File ".\nativeLang\" @@ -131,6 +131,7 @@ Function copyCommonFiles CopyFiles "$PLUGINSDIR\nppLocalization\$(langFileName)" "$INSTDIR\localization\$(langFileName)" IfFileExists "$PLUGINSDIR\gupLocalization\$(langFileName)" 0 +2 CopyFiles "$PLUGINSDIR\gupLocalization\$(langFileName)" "$INSTDIR\updater\nativeLang.xml" + FunctionEnd ; Source from: https://nsis.sourceforge.io/VersionCompare diff --git a/PowerEditor/installer/nsisInclude/uninstall.nsh b/PowerEditor/installer/nsisInclude/uninstall.nsh index d2e5ba5cf..6fe02ffc1 100644 --- a/PowerEditor/installer/nsisInclude/uninstall.nsh +++ b/PowerEditor/installer/nsisInclude/uninstall.nsh @@ -50,6 +50,12 @@ Function un.onUninstSuccess FunctionEnd +!include "StrFunc.nsh" +${Using:StrFunc} UnStrStr + +Var muiVerbStrUn +Var nppSubStrUn + Section un.explorerContextMenu Exec 'regsvr32 /u /s "$INSTDIR\NppShell_01.dll"' Exec 'regsvr32 /u /s "$INSTDIR\NppShell_02.dll"' @@ -63,6 +69,17 @@ Section un.explorerContextMenu Delete "$INSTDIR\NppShell_04.dll" Delete "$INSTDIR\NppShell_05.dll" Delete "$INSTDIR\NppShell_06.dll" + + + ReadRegStr $muiVerbStrUn HKLM "SOFTWARE\Classes\*\shell\pintohome" MUIVerb + ${UnStrStr} $nppSubStrUn $muiVerbStrUn "Notepad++" + + ; Make sure there's an entry, and the entry belong to Notepad++ before deleting it + ${If} $muiVerbStrUn != "" + ${AndIf} $nppSubStrUn != "" ; it contains "Notepad++" + DeleteRegKey HKLM "SOFTWARE\Classes\*\shell\pintohome" + + ${EndIf} SectionEnd Section un.UnregisterFileExt diff --git a/PowerEditor/installer/nsisInclude/winVer.nsh b/PowerEditor/installer/nsisInclude/winVer.nsh index 4fcd09886..c95972dd5 100644 --- a/PowerEditor/installer/nsisInclude/winVer.nsh +++ b/PowerEditor/installer/nsisInclude/winVer.nsh @@ -42,14 +42,12 @@ Function GetWindowsVersion ClearErrors ; check if Windows NT family - ReadRegStr $R0 HKLM \ - "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion + ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion IfErrors 0 lbl_winnt ; we are not NT - ReadRegStr $R0 HKLM \ - "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber + ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber StrCpy $R1 $R0 1 StrCmp $R1 '4' 0 lbl_error @@ -59,19 +57,19 @@ Function GetWindowsVersion StrCmp $R1 '4.0' lbl_win32_95 StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98 - lbl_win32_95: - StrCpy $R0 '95' +lbl_win32_95: + StrCpy $R0 '95' Goto lbl_done - lbl_win32_98: - StrCpy $R0 '98' +lbl_win32_98: + StrCpy $R0 '98' Goto lbl_done - lbl_win32_ME: - StrCpy $R0 'ME' +lbl_win32_ME: + StrCpy $R0 'ME' Goto lbl_done - lbl_winnt: +lbl_winnt: StrCpy $R1 $R0 1 @@ -94,46 +92,56 @@ Function GetWindowsVersion StrCmp $R1 '10.0' lbl_winnt_10 Goto lbl_error - lbl_winnt_x: - StrCpy $R0 "NT $R0" 6 +lbl_winnt_x: + StrCpy $R0 "NT $R0" 6 Goto lbl_done - lbl_winnt_2000: - Strcpy $R0 '2000' +lbl_winnt_2000: + Strcpy $R0 '2000' Goto lbl_done - lbl_winnt_XP: - Strcpy $R0 'XP' +lbl_winnt_XP: + Strcpy $R0 'XP' Goto lbl_done - lbl_winnt_2003: - Strcpy $R0 '2003' +lbl_winnt_2003: + Strcpy $R0 '2003' Goto lbl_done - lbl_winnt_vista: - Strcpy $R0 'Vista' +lbl_winnt_vista: + Strcpy $R0 'Vista' Goto lbl_done - lbl_winnt_7: - Strcpy $R0 '7' +lbl_winnt_7: + Strcpy $R0 '7' Goto lbl_done - lbl_winnt_8: - Strcpy $R0 '8' +lbl_winnt_8: + Strcpy $R0 '8' Goto lbl_done - lbl_winnt_81: +lbl_winnt_81: +lbl_winnt_10: + ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentBuildNumber + ${If} $R0 >= 17763 ; Windows 10 or later + ${If} $R0 >= 22000 ; Windows 11 or later + Strcpy $R0 '11' + Goto lbl_done + ${Else} + Strcpy $R0 '10' + Goto lbl_done + ${EndIf} + + ${Else} Strcpy $R0 '8.1' + Goto lbl_done + ${EndIf} Goto lbl_done - lbl_winnt_10: - Strcpy $R0 '10.0' - Goto lbl_done - - lbl_error: - Strcpy $R0 '' - lbl_done: - +lbl_error: + Strcpy $R0 '' + +lbl_done: Pop $R1 Exch $R0