diff --git a/PowerEditor/installer/nativeLang/explorerContextMenuEntryLocal.ini b/PowerEditor/installer/nativeLang/explorerContextMenuEntryLocal.ini new file mode 100644 index 000000000..b30195706 Binary files /dev/null and b/PowerEditor/installer/nativeLang/explorerContextMenuEntryLocal.ini differ 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