diff --git a/PowerEditor/installer/nppSetup.nsi b/PowerEditor/installer/nppSetup.nsi index 9e4a82a1a..dddc1645b 100644 --- a/PowerEditor/installer/nppSetup.nsi +++ b/PowerEditor/installer/nppSetup.nsi @@ -270,65 +270,43 @@ Var nppSubStr ${MementoSection} "Context Menu Entry" explorerContextMenu - ${If} $WinVer == "11" - - ; Clean up the hack of v8.5 installer - ReadRegStr $muiVerbStr HKLM "SOFTWARE\Classes\*\shell\pintohome" MUIVerb - ${StrStr} $nppSubStr $muiVerbStr "Notepad++" - ; Make sure there's an entry, and the entry belong to Notepad++ before deleting it - ${If} $muiVerbStr != "" - ${AndIf} $nppSubStr != "" ; it contains "Notepad++" - DeleteRegKey HKLM "SOFTWARE\Classes\*\shell\pintohome" - ${EndIf} - - ; Install the new Windows 11 "Edit with Notepad++" menu entry - !ifdef ARCHARM64 - File /oname=$INSTDIR\NppModernShell.msix "..\binarm64\NppModernShell.msix" - File /oname=$INSTDIR\NppModernShell.dll "..\binarm64\NppModernShell.dll" - !else ; !ifdef ARCH64 - File /oname=$INSTDIR\NppModernShell.msix "..\bin64\NppModernShell.msix" - File /oname=$INSTDIR\NppModernShell.dll "..\bin64\NppModernShell.dll" - !endif - Exec 'rundll32.exe "$INSTDIR\NppModernShell.dll",RegisterSparsePackage' + SetOverwrite try + SetOutPath "$INSTDIR\contextmenu\" - ; Make sure old NppShell dll's are unregistered and removed - Exec 'regsvr32 /u /s "$INSTDIR\NppShell_01.dll"' - Exec 'regsvr32 /u /s "$INSTDIR\NppShell_02.dll"' - Exec 'regsvr32 /u /s "$INSTDIR\NppShell_03.dll"' - Exec 'regsvr32 /u /s "$INSTDIR\NppShell_04.dll"' - Exec 'regsvr32 /u /s "$INSTDIR\NppShell_05.dll"' - Exec 'regsvr32 /u /s "$INSTDIR\NppShell_06.dll"' - Delete "$INSTDIR\NppShell_01.dll" - Delete "$INSTDIR\NppShell_02.dll" - Delete "$INSTDIR\NppShell_03.dll" - Delete "$INSTDIR\NppShell_04.dll" - Delete "$INSTDIR\NppShell_05.dll" - Delete "$INSTDIR\NppShell_06.dll" - - ${Else} ; the old "Edit with Notepad++" menu entry still works under Windows 10 and previous OS - - SetOverwrite try - SetOutPath "$INSTDIR\" - - ; There is no need to keep x86 NppShell_06.dll in 64 bit installer - ; But in 32bit installer both the Dlls are required - ; As user can install 32bit npp version on x64 bit machine, that time x64 bit NppShell is required. - - !ifdef ARCH64 - File /oname=$INSTDIR\NppShell_06.dll "..\bin\NppShell64_06.dll" - !else ifdef ARCHARM64 - File /oname=$INSTDIR\NppShell_06.dll "..\binarm64\NppShell64.dll" - !else - ${If} ${RunningX64} - File /oname=$INSTDIR\NppShell_06.dll "..\bin\NppShell64_06.dll" - ${Else} - File "..\bin\NppShell_06.dll" - ${EndIf} - !endif - Exec 'regsvr32 /s "$INSTDIR\NppShell_06.dll"' + !ifdef ARCH64 + File /oname=$INSTDIR\contextmenu\NppShell.msix "..\bin64\NppShell.msix" + File /oname=$INSTDIR\contextmenu\NppShell.dll "..\bin64\NppShell.x64.dll" + !else ifdef ARCHARM64 + File /oname=$INSTDIR\contextmenu\NppShell.msix "..\binarm64\NppShell.msix" + File /oname=$INSTDIR\contextmenu\NppShell.dll "..\binarm64\NppShell.arm64.dll" + !else + ; We need to test which arch we are running on, since 32bit exe can be run on both 32bit and 64bit Windows. + ${If} ${RunningX64} + ; We are running on 64bit Windows, so we need the msix as well, since it might be Windows 11. + File /oname=$INSTDIR\contextmenu\NppShell.msix "..\bin64\NppShell.msix" + File /oname=$INSTDIR\contextmenu\NppShell.dll "..\bin64\NppShell.x64.dll" + ${Else} + ; We are running on 32bit Windows, so no need for the msix file, since there is no way this could even be upgraded to Windows 11. + File /oname=$INSTDIR\contextmenu\NppShell.dll "..\bin\NppShell.x86.dll" + ${EndIf} + + !endif + Exec 'regsvr32 /s "$INSTDIR\contextmenu\NppShell.dll"' + + ; Make sure old NppShell dll's are unregistered and removed + Exec 'regsvr32 /u /s "$INSTDIR\NppShell_01.dll"' + Exec 'regsvr32 /u /s "$INSTDIR\NppShell_02.dll"' + Exec 'regsvr32 /u /s "$INSTDIR\NppShell_03.dll"' + Exec 'regsvr32 /u /s "$INSTDIR\NppShell_04.dll"' + Exec 'regsvr32 /u /s "$INSTDIR\NppShell_05.dll"' + Exec 'regsvr32 /u /s "$INSTDIR\NppShell_06.dll"' + Delete "$INSTDIR\NppShell_01.dll" + Delete "$INSTDIR\NppShell_02.dll" + Delete "$INSTDIR\NppShell_03.dll" + Delete "$INSTDIR\NppShell_04.dll" + Delete "$INSTDIR\NppShell_05.dll" + Delete "$INSTDIR\NppShell_06.dll" - ${EndIf} - ${MementoSectionEnd} ${MementoSectionDone} diff --git a/PowerEditor/installer/nsisInclude/uninstall.nsh b/PowerEditor/installer/nsisInclude/uninstall.nsh index 1e13db5c3..366ae07ec 100644 --- a/PowerEditor/installer/nsisInclude/uninstall.nsh +++ b/PowerEditor/installer/nsisInclude/uninstall.nsh @@ -43,11 +43,13 @@ Function un.onUninstSuccess RMDir "$INSTDIR\autoCompletion\" RMDir "$INSTDIR\functionList\" RMDir "$INSTDIR\themes\" + RMDir "$INSTDIR\contextmenu\" RMDir "$INSTDIR\" RMDir "$APPDATA\${APPNAME}\plugins\" RMDir "$installPath\themes\" ; if files are kept because of $keepUserData, this will not be deleted RMDir "$installPath\userDefineLangs\" + RMDir "$installPath\contextmenu\" RMDir "$installPath\" FunctionEnd @@ -72,19 +74,9 @@ Section un.explorerContextMenu Delete "$INSTDIR\NppShell_05.dll" Delete "$INSTDIR\NppShell_06.dll" - Exec 'rundll32.exe "$INSTDIR\NppModernShell.dll",UnregisterSparsePackage' - ;Delete "$INSTDIR\NppModernShell.dll" - ;Delete "$INSTDIR\NppModernShell.msix" - - 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} + Exec 'regsvr32 /u /s "$INSTDIR\contextmenu\NppShell.dll"' + ;Delete "$INSTDIR\contextmenu\NppShell.dll" + ;Delete "$INSTDIR\contextmenu\NppShell.msix" SectionEnd Section un.UnregisterFileExt @@ -306,9 +298,9 @@ Section Uninstall ${endIf} ; In order to not delete context menu binary before we unregistered it, - ; we delete them at the end - Delete "$INSTDIR\NppModernShell.dll" - Delete "$INSTDIR\NppModernShell.msix" + ; we delete them at the end, using the CleanupDll function, since it can be locked by explorer. + Exec 'rundll32.exe "$INSTDIR\contextmenu\NppShell.dll",CleanupDll' + Delete "$INSTDIR\contextmenu\NppShell.msix" ; Remove remaining directories @@ -318,6 +310,7 @@ Section Uninstall RMDir "$INSTDIR\themes\" RMDir "$INSTDIR\localization\" RMDir "$INSTDIR\functionList\" + RMDir "$INSTDIR\contextmenu\" RMDir "$INSTDIR\" RMDir "$SMPROGRAMS\${APPNAME}" diff --git a/PowerEditor/installer/packageAll.bat b/PowerEditor/installer/packageAll.bat index ebd6c0efa..3cbbadf85 100644 --- a/PowerEditor/installer/packageAll.bat +++ b/PowerEditor/installer/packageAll.bat @@ -33,20 +33,15 @@ If ErrorLevel 1 goto End %signArmBinary% ..\binarm64\notepad++.exe If ErrorLevel 1 goto End -%signBinary% ..\bin\NppShell_06.dll +%signBinary% ..\bin\NppShell.x86.dll If ErrorLevel 1 goto End -%signBinary% ..\bin\NppShell64_06.dll +%signBinary% ..\bin64\NppShell.msix If ErrorLevel 1 goto End -%signArmBinary% ..\binarm64\NppShell64.dll +%signBinary% ..\bin64\NppShell.x64.dll If ErrorLevel 1 goto End - -%signBinary% ..\bin64\NppModernShell.msix +%signBinary% ..\binarm64\NppShell.msix If ErrorLevel 1 goto End -%signBinary% ..\bin64\NppModernShell.dll -If ErrorLevel 1 goto End -%signBinary% ..\binarm64\NppModernShell.msix -If ErrorLevel 1 goto End -%signArmBinary% ..\binarm64\NppModernShell.dll +%signArmBinary% ..\binarm64\NppShell.arm64.dll If ErrorLevel 1 goto End %signBinary% ..\bin\plugins\Config\nppPluginList.dll diff --git a/PowerEditor/src/tools/NppModernShell/.gitignore b/PowerEditor/src/tools/NppModernShell/.gitignore deleted file mode 100644 index a41d7220a..000000000 --- a/PowerEditor/src/tools/NppModernShell/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -packages -Packaging/NppModernShell.msix \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/CommandHandlerFactory.cpp b/PowerEditor/src/tools/NppModernShell/CommandHandlerFactory.cpp deleted file mode 100644 index defd9e508..000000000 --- a/PowerEditor/src/tools/NppModernShell/CommandHandlerFactory.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "pch.h" -#include "CommandHandlerFactory.h" - -#include "EditWithNppExplorerCommandHandler.h" - -using namespace NppModernShell::CommandHandlers; -using namespace NppModernShell::Factories; - -IFACEMETHODIMP CommandHandlerFactory::CreateInstance(_In_opt_ IUnknown* pUnkOuter, _In_ REFIID riid, _COM_Outptr_ void** ppvObject) noexcept -{ - UNREFERENCED_PARAMETER(pUnkOuter); - - try - { - return winrt::make()->QueryInterface(riid, ppvObject); - } - catch (...) - { - return winrt::to_hresult(); - } -} - -IFACEMETHODIMP CommandHandlerFactory::LockServer(_In_ BOOL fLock) noexcept -{ - if (fLock) - { - ++winrt::get_module_lock(); - } - else - { - --winrt::get_module_lock(); - } - - return S_OK; -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/CommandHandlerFactory.h b/PowerEditor/src/tools/NppModernShell/CommandHandlerFactory.h deleted file mode 100644 index 786835a57..000000000 --- a/PowerEditor/src/tools/NppModernShell/CommandHandlerFactory.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "pch.h" - -namespace NppModernShell::Factories -{ - class __declspec(uuid("4EACAA14-3B43-4595-A44C-FBA8F0848620")) CommandHandlerFactory : public winrt::implements - { - public: - IFACEMETHODIMP CreateInstance(_In_opt_ IUnknown* pUnkOuter, _In_ REFIID riid, _COM_Outptr_ void** ppvObject) noexcept override; - IFACEMETHODIMP LockServer(_In_ BOOL fLock) noexcept override; - }; -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/EditWithNppExplorerCommandHandler.cpp b/PowerEditor/src/tools/NppModernShell/EditWithNppExplorerCommandHandler.cpp deleted file mode 100644 index 82bd82427..000000000 --- a/PowerEditor/src/tools/NppModernShell/EditWithNppExplorerCommandHandler.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "pch.h" -#include "EditWithNppExplorerCommandHandler.h" - -#include "Helpers.h" - -using namespace NppModernShell::CommandHandlers; -using namespace NppModernShell::Helpers; - -const wstring EditWithNppExplorerCommandHandler::GetNppExecutableFullPath() -{ - const wstring path = GetInstallationPath(); - const wstring fileName = L"\\notepad++.exe"; - - return L"\"" + path + fileName + L"\""; -} - -const wstring EditWithNppExplorerCommandHandler::Title() -{ - return L"Edit with Notepad++"; -} - -const wstring EditWithNppExplorerCommandHandler::Icon() -{ - const wstring fileName = GetNppExecutableFullPath(); - - return fileName; -} - -const wstring EditWithNppExplorerCommandHandler::GetCommandLine() -{ - const wstring fileName = GetNppExecutableFullPath(); - const wstring parameters = L"\"%1\""; - - return fileName + L" " + parameters; -} - -IFACEMETHODIMP EditWithNppExplorerCommandHandler::Invoke(_In_opt_ IShellItemArray* selection, _In_opt_ IBindCtx*) noexcept try -{ - if (!selection) - { - return S_OK; - } - - DWORD count; - RETURN_IF_FAILED(selection->GetCount(&count)); - - IShellItem* psi; - LPWSTR itemName; - - for (DWORD i = 0; i < count; ++i) - { - selection->GetItemAt(i, &psi); - RETURN_IF_FAILED(psi->GetDisplayName(SIGDN_FILESYSPATH, &itemName)); - - std::wstring cmdline = this->GetCommandLine(); - cmdline = cmdline.replace(cmdline.find(L"%1"), 2, itemName); - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - ZeroMemory(&pi, sizeof(pi)); - - wchar_t* command = (LPWSTR)cmdline.c_str(); - - if (!CreateProcess(nullptr, command, nullptr, nullptr, false, CREATE_NEW_PROCESS_GROUP, nullptr, nullptr, &si, &pi)) - { - return S_OK; - } - - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - } - - return S_OK; -} -CATCH_RETURN(); \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/EditWithNppExplorerCommandHandler.h b/PowerEditor/src/tools/NppModernShell/EditWithNppExplorerCommandHandler.h deleted file mode 100644 index 0da41c934..000000000 --- a/PowerEditor/src/tools/NppModernShell/EditWithNppExplorerCommandHandler.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "pch.h" - -#include "ExplorerCommandBase.h" - -namespace NppModernShell::CommandHandlers -{ - class EditWithNppExplorerCommandHandler : public ExplorerCommandBase - { - public: - const wstring Title() override; - const wstring Icon() override; - - IFACEMETHODIMP Invoke(_In_opt_ IShellItemArray* selection, _In_opt_ IBindCtx*) noexcept override; - - private: - const wstring GetNppExecutableFullPath(); - const wstring GetCommandLine(); - }; -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/ExplorerCommandBase.cpp b/PowerEditor/src/tools/NppModernShell/ExplorerCommandBase.cpp deleted file mode 100644 index d2b8017f8..000000000 --- a/PowerEditor/src/tools/NppModernShell/ExplorerCommandBase.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "pch.h" -#include "ExplorerCommandBase.h" - -using namespace NppModernShell::CommandHandlers; - -const EXPCMDFLAGS ExplorerCommandBase::Flags() -{ - return ECF_DEFAULT; -} - -const EXPCMDSTATE ExplorerCommandBase::State(_In_opt_ IShellItemArray* selection) -{ - UNREFERENCED_PARAMETER(selection); - - return ECS_ENABLED; -} - -IFACEMETHODIMP ExplorerCommandBase::GetTitle(_In_opt_ IShellItemArray* items, _Outptr_result_nullonfailure_ PWSTR* name) -{ - UNREFERENCED_PARAMETER(items); - - *name = nullptr; - auto str = wil::make_cotaskmem_string_nothrow(Title().c_str()); - RETURN_IF_NULL_ALLOC(str); - *name = str.release(); - return S_OK; -} - -IFACEMETHODIMP ExplorerCommandBase::GetIcon(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* icon) -{ - *icon = nullptr; - auto str = wil::make_cotaskmem_string_nothrow(Icon().c_str()); - RETURN_IF_NULL_ALLOC(str); - *icon = str.release(); - return S_OK; -} - -IFACEMETHODIMP ExplorerCommandBase::GetToolTip(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* infoTip) -{ - *infoTip = nullptr; - return E_NOTIMPL; -} - -IFACEMETHODIMP ExplorerCommandBase::GetState(_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState) -{ - UNREFERENCED_PARAMETER(okToBeSlow); - - *cmdState = State(selection); - return S_OK; -} - -IFACEMETHODIMP ExplorerCommandBase::GetFlags(_Out_ EXPCMDFLAGS* flags) -{ - *flags = Flags(); - return S_OK; -} - -IFACEMETHODIMP ExplorerCommandBase::GetCanonicalName(_Out_ GUID* guidCommandName) -{ - *guidCommandName = GUID_NULL; - return E_NOTIMPL; -} - -IFACEMETHODIMP ExplorerCommandBase::EnumSubCommands(_COM_Outptr_ IEnumExplorerCommand** enumCommands) -{ - *enumCommands = nullptr; - return E_NOTIMPL; -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/ExplorerCommandBase.h b/PowerEditor/src/tools/NppModernShell/ExplorerCommandBase.h deleted file mode 100644 index c3cbb5b22..000000000 --- a/PowerEditor/src/tools/NppModernShell/ExplorerCommandBase.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "pch.h" - -namespace NppModernShell::CommandHandlers -{ - class ExplorerCommandBase : public winrt::implements - { - public: - virtual const wstring Title() = 0; - virtual const wstring Icon() = 0; - virtual const EXPCMDFLAGS Flags(); - virtual const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection); - - IFACEMETHODIMP GetTitle(_In_opt_ IShellItemArray* items, _Outptr_result_nullonfailure_ PWSTR* name); - IFACEMETHODIMP GetIcon(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* icon); - IFACEMETHODIMP GetToolTip(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* infoTip); - IFACEMETHODIMP GetState(_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState); - IFACEMETHODIMP GetFlags(_Out_ EXPCMDFLAGS* flags); - IFACEMETHODIMP GetCanonicalName(_Out_ GUID* guidCommandName); - IFACEMETHODIMP EnumSubCommands(_COM_Outptr_ IEnumExplorerCommand** enumCommands); - - virtual IFACEMETHODIMP Invoke(_In_opt_ IShellItemArray* selection, _In_opt_ IBindCtx*) noexcept = 0; - }; -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/Helpers.cpp b/PowerEditor/src/tools/NppModernShell/Helpers.cpp deleted file mode 100644 index 97cbb661b..000000000 --- a/PowerEditor/src/tools/NppModernShell/Helpers.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pch.h" -#include "Helpers.h" - -using namespace NppModernShell::Helpers; - -const HMODULE GetThisModule() -{ - HMODULE hm = NULL; - - BOOL result = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)&GetInstallationPath, &hm); - - if (result == FALSE) - { - throw "Failed to locate current module, unable to proceed"; - } - - return hm; -} - -const wstring NppModernShell::Helpers::GetInstallationPath() -{ - HMODULE thisModule = GetThisModule(); - - wchar_t path[FILENAME_MAX] = { 0 }; - GetModuleFileName(thisModule, path, FILENAME_MAX); - return std::filesystem::path(path).parent_path().wstring(); -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/Helpers.h b/PowerEditor/src/tools/NppModernShell/Helpers.h deleted file mode 100644 index 2bc82490d..000000000 --- a/PowerEditor/src/tools/NppModernShell/Helpers.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "pch.h" - -#include - -namespace NppModernShell::Helpers -{ - const wstring GetInstallationPath(); -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/Installer.cpp b/PowerEditor/src/tools/NppModernShell/Installer.cpp deleted file mode 100644 index 8b23e911d..000000000 --- a/PowerEditor/src/tools/NppModernShell/Installer.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "pch.h" -#include "Installer.h" - -using namespace winrt::Windows::ApplicationModel; -using namespace winrt::Windows::Foundation; -using namespace winrt::Windows::Foundation::Collections; -using namespace winrt::Windows::Management::Deployment; - -using namespace NppModernShell::Helpers; -using namespace NppModernShell::Installer; - -const wstring SparsePackageName = L"NotepadPlusPlus"; - -STDAPI NppModernShell::Installer::RegisterSparsePackage() -{ - PackageManager packageManager; - AddPackageOptions options; - - const wstring externalLocation = GetInstallationPath(); - const wstring sparsePkgPath = externalLocation + L"\\NppModernShell.msix"; - - Uri externalUri(externalLocation); - Uri packageUri(sparsePkgPath); - - options.ExternalLocationUri(externalUri); - - auto deploymentOperation = packageManager.AddPackageByUriAsync(packageUri, options); - auto deployResult = deploymentOperation.get(); - - if (!SUCCEEDED(deployResult.ExtendedErrorCode())) - { - return deployResult.ExtendedErrorCode(); - } - - return S_OK; -} - -STDAPI NppModernShell::Installer::UnregisterSparsePackage() -{ - PackageManager packageManager; - IIterable packages; - - try - { - packages = packageManager.FindPackagesForUser(L""); - } - catch (winrt::hresult_error const& ex) - { - return ex.code(); - } - - for (const Package& package : packages) - { - if (package.Id().Name() != SparsePackageName) - { - continue; - } - - winrt::hstring fullName = package.Id().FullName(); - auto deploymentOperation = packageManager.RemovePackageAsync(fullName, RemovalOptions::None); - auto deployResult = deploymentOperation.get(); - - if (!SUCCEEDED(deployResult.ExtendedErrorCode())) - { - return deployResult.ExtendedErrorCode(); - } - - break; - } - - return S_OK; -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/Installer.h b/PowerEditor/src/tools/NppModernShell/Installer.h deleted file mode 100644 index ac566f7d0..000000000 --- a/PowerEditor/src/tools/NppModernShell/Installer.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "pch.h" - -#include "Helpers.h" - -namespace NppModernShell::Installer -{ - STDAPI RegisterSparsePackage(); - STDAPI UnregisterSparsePackage(); -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/NppModernShell.sln b/PowerEditor/src/tools/NppModernShell/NppModernShell.sln deleted file mode 100644 index d28cc4acb..000000000 --- a/PowerEditor/src/tools/NppModernShell/NppModernShell.sln +++ /dev/null @@ -1,39 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33414.496 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NppModernShell", "NppModernShell.vcxproj", "{E7539F55-2932-47D0-82B8-46ED5AFCA1C0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packaging", "Packaging", "{B9E2DBFF-8940-482F-9D07-BA9C4EAE7620}" - ProjectSection(SolutionItems) = preProject - Packaging\AppxManifest.xml = Packaging\AppxManifest.xml - Packaging\Square150x150Logo.png = Packaging\Square150x150Logo.png - Packaging\Square44x44Logo.png = Packaging\Square44x44Logo.png - Packaging\StoreLogo.png = Packaging\StoreLogo.png - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Debug|ARM64.Build.0 = Debug|ARM64 - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Debug|x64.ActiveCfg = Debug|x64 - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Debug|x64.Build.0 = Debug|x64 - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Release|ARM64.ActiveCfg = Release|ARM64 - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Release|ARM64.Build.0 = Release|ARM64 - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Release|x64.ActiveCfg = Release|x64 - {E7539F55-2932-47D0-82B8-46ED5AFCA1C0}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {EAA0AA08-253D-435A-929E-9214D1E358CB} - EndGlobalSection -EndGlobal diff --git a/PowerEditor/src/tools/NppModernShell/NppModernShell.vcxproj b/PowerEditor/src/tools/NppModernShell/NppModernShell.vcxproj deleted file mode 100644 index a6074a377..000000000 --- a/PowerEditor/src/tools/NppModernShell/NppModernShell.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - ARM64 - - - Debug - x64 - - - Release - ARM64 - - - Release - x64 - - - - 16.0 - Win32Proj - {e7539f55-2932-47d0-82b8-46ed5afca1c0} - NppModernShell - 10.0 - - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level4 - true - _DEBUG;NPPMODERNSHELL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - stdcpp20 - MultiThreadedDebug - true - - - Windows - true - false - shlwapi.lib;runtimeobject.lib;%(AdditionalDependencies) - source.def - - - makeappx pack /d .\Packaging /p $(OutDir)NppModernShell.msix /nv - - - - - Level4 - true - _DEBUG;NPPMODERNSHELL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - stdcpp20 - MultiThreadedDebug - true - - - Windows - true - false - shlwapi.lib;runtimeobject.lib;%(AdditionalDependencies) - source.def - - - makeappx pack /d .\Packaging /p $(OutDir)NppModernShell.msix /nv - - - - - Level4 - true - true - true - NDEBUG;NPPMODERNSHELL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - stdcpp20 - MultiThreaded - true - - - Windows - true - true - true - false - shlwapi.lib;runtimeobject.lib;%(AdditionalDependencies) - source.def - - - makeappx pack /d .\Packaging /p $(OutDir)NppModernShell.msix /nv - - - - - Level4 - true - true - true - NDEBUG;NPPMODERNSHELL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - stdcpp20 - MultiThreaded - true - - - Windows - true - true - true - false - shlwapi.lib;runtimeobject.lib;%(AdditionalDependencies) - source.def - - - makeappx pack /d .\Packaging /p $(OutDir)NppModernShell.msix /nv - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/NppModernShell.vcxproj.filters b/PowerEditor/src/tools/NppModernShell/NppModernShell.vcxproj.filters deleted file mode 100644 index 164737779..000000000 --- a/PowerEditor/src/tools/NppModernShell/NppModernShell.vcxproj.filters +++ /dev/null @@ -1,55 +0,0 @@ - - - - - {ff31b0d8-bf03-4a28-945d-cfae6eb365fa} - - - {3ce00d49-8c93-43bf-8d92-00c9b7087776} - - - {ca898efe-24d8-4317-99c9-769e8e80c3aa} - - - - - CommandHandlers - - - CommandHandlers - - - Installer - - - Factories - - - - - - - - CommandHandlers - - - CommandHandlers - - - Installer - - - - - - Factories - - - - - - - - - - \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/Packaging/AppxManifest.xml b/PowerEditor/src/tools/NppModernShell/Packaging/AppxManifest.xml deleted file mode 100644 index 28ffaa987..000000000 --- a/PowerEditor/src/tools/NppModernShell/Packaging/AppxManifest.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - Notepad++ - Notepad++ - StoreLogo.png - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/Packaging/Square150x150Logo.png b/PowerEditor/src/tools/NppModernShell/Packaging/Square150x150Logo.png deleted file mode 100644 index 14aaf5440..000000000 Binary files a/PowerEditor/src/tools/NppModernShell/Packaging/Square150x150Logo.png and /dev/null differ diff --git a/PowerEditor/src/tools/NppModernShell/Packaging/Square44x44Logo.png b/PowerEditor/src/tools/NppModernShell/Packaging/Square44x44Logo.png deleted file mode 100644 index 488dcdf47..000000000 Binary files a/PowerEditor/src/tools/NppModernShell/Packaging/Square44x44Logo.png and /dev/null differ diff --git a/PowerEditor/src/tools/NppModernShell/Packaging/StoreLogo.png b/PowerEditor/src/tools/NppModernShell/Packaging/StoreLogo.png deleted file mode 100644 index dcab10a55..000000000 Binary files a/PowerEditor/src/tools/NppModernShell/Packaging/StoreLogo.png and /dev/null differ diff --git a/PowerEditor/src/tools/NppModernShell/README.md b/PowerEditor/src/tools/NppModernShell/README.md deleted file mode 100644 index a34ff8f2a..000000000 --- a/PowerEditor/src/tools/NppModernShell/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Windows 11 Modern UI Context Menu integration - -The purpose of this project is to allow Notepad++ to integrate into the new Windows 11 right-click context menu. -Doing this requires two new things. - -* A dll library with some COM objects that the shell can communicate with. -* A Sparse Package containing the metadata for the COM server. - -To build this, the following steps needs to be taken: - -1. Build a Release dll file (NppModernShell.dll) -2. Generate a Sparse Package (NppModernShell.msix) -3. Sign both of these with signtool.exe -4. Make sure they are included in the installer, so they are deployed next to the notepad++.exe program. -5. The installer should, upon installation, install the package. -6. The installer should, upon uninstallation, uninstall the package. - -## Prerequisites - -To be able to build this project, the following is needed: - -* [Visual Studio 2022](https://visualstudio.microsoft.com/vs) -* [Windows 11 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk) - -## Build a Release dll file (NppModernShell.dll) -Just open the NppModernShell.sln Visual Studio solution, select Release as the build type, and do a Rebuild of the solution. - -## Generate a Sparse Package (NppModernShell.msix) -To generate a Sparse Package, you need to have the makeappx.exe tool in your PATH, the easiest way to do this is to run the `Developer Command Prompt for VS 2022` command prompt, since it sets up the path. -Once inside the NppModernShell folder, run the following command to generate the Sparse Package: -``` -makeappx pack /d .\Packaging /p .\NppModernShell.msix /nv -``` -This takes the content of the Packaging directory, and packages them up into the msix file. - -## Sign both of these with signtool.exe -Now we have both the `NppModernShell.dll` and `NppModernShell.msix` files, we need to sign them with a valid certificate. -To do this, once again run the `Developer Command Prompt for VS 2022` command prompt and change to the NppModernShell folder. -The following command expects the following: -* The pfx certificate is called MyCert.pfx -* The password for the pfx certificate is: `Test1234` - -Make the needed changes to match the real certificate. -``` -SignTool.exe sign /fd SHA256 /tr http://timestamp.digicert.com /td sha256 /a /f .\MyCert.pfx /p Test1234 /d "Notepad++" /du https://notepad-plus-plus.org/ NppModernShell.msix -SignTool.exe sign /fd SHA256 /tr http://timestamp.digicert.com /td sha256 /a /f .\MyCert.pfx /p Test1234 /d "Notepad++" /du https://notepad-plus-plus.org/ x64\Release\NppModernShell.dll -``` -Now both files has been signed, and can be used. - -## Make sure they are included in the installer, so they are deployed next to the notepad++.exe program. -The installer needs to deploy the two files into the same directory as notepad++.exe . -They need to be there, since the DLL is looking for notepad++.exe in the same directory as it is located itself. - -## The installer should, upon installation, install the package. -When the installer is running, after all the files has been copied into the program files directory, the follow command should be be run to run the register function to register the package: -``` -rundll32.exe .\NppModernShell.dll,RegisterSparsePackage -``` - -Remember to wait for the rundll32 process to exit before continuing. - -## The installer should, upon uninstallation, uninstall the package. -When the uninstaller is running, it should run this command to unregister the package: -``` -rundll32.exe .\NppModernShell.dll,UnregisterSparsePackage -``` - -Here we need to wait for rundll32 to finish, since if it isn't finished, the dll file will be locked by explorer. \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/dllmain.cpp b/PowerEditor/src/tools/NppModernShell/dllmain.cpp deleted file mode 100644 index 20045ba31..000000000 --- a/PowerEditor/src/tools/NppModernShell/dllmain.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "pch.h" - -#include "CommandHandlerFactory.h" - -using namespace NppModernShell::Factories; - -BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - UNREFERENCED_PARAMETER(hModule); - UNREFERENCED_PARAMETER(lpReserved); - - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - - return TRUE; -} - -__control_entrypoint(DllExport) -STDAPI DllCanUnloadNow(void) -{ - if (winrt::get_module_lock()) - { - return S_FALSE; - } - - winrt::clear_factory_cache(); - return S_OK; -} - -_Check_return_ -STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID FAR* ppv) -{ - if (!ppv) - { - return E_POINTER; - } - - if (riid != IID_IClassFactory && riid != IID_IUnknown) - { - return E_NOINTERFACE; - } - - if (rclsid != __uuidof(CommandHandlerFactory)) - { - return E_INVALIDARG; - } - - try - { - return winrt::make()->QueryInterface(riid, ppv); - } - catch (...) - { - return winrt::to_hresult(); - } -} \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/framework.h b/PowerEditor/src/tools/NppModernShell/framework.h deleted file mode 100644 index 6ad3bcca9..000000000 --- a/PowerEditor/src/tools/NppModernShell/framework.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include -#include -#include - -// WinRT Header Files -#include -#include -#include -#include - -// Windows Implementation Library Header Files -#include "wil\winrt.h" \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/packages.config b/PowerEditor/src/tools/NppModernShell/packages.config deleted file mode 100644 index 22819475c..000000000 --- a/PowerEditor/src/tools/NppModernShell/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/PowerEditor/src/tools/NppModernShell/pch.cpp b/PowerEditor/src/tools/NppModernShell/pch.cpp deleted file mode 100644 index 64b7eef6d..000000000 --- a/PowerEditor/src/tools/NppModernShell/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/PowerEditor/src/tools/NppModernShell/pch.h b/PowerEditor/src/tools/NppModernShell/pch.h deleted file mode 100644 index 1581b7622..000000000 --- a/PowerEditor/src/tools/NppModernShell/pch.h +++ /dev/null @@ -1,15 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H - -// add headers that you want to pre-compile here -#include "framework.h" - -using namespace std; - -#endif //PCH_H diff --git a/PowerEditor/src/tools/NppModernShell/source.def b/PowerEditor/src/tools/NppModernShell/source.def deleted file mode 100644 index 80f5f9896..000000000 --- a/PowerEditor/src/tools/NppModernShell/source.def +++ /dev/null @@ -1,6 +0,0 @@ -LIBRARY -EXPORTS -DllCanUnloadNow PRIVATE -DllGetClassObject PRIVATE -RegisterSparsePackage -UnregisterSparsePackage \ No newline at end of file diff --git a/PowerEditor/src/tools/NppShell/project/NppShell.sln b/PowerEditor/src/tools/NppShell/project/NppShell.sln deleted file mode 100644 index 63a166e97..000000000 --- a/PowerEditor/src/tools/NppShell/project/NppShell.sln +++ /dev/null @@ -1,37 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.779 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NppShell", "NppShell.vcxproj", "{509B95C6-043E-4389-8351-77BDB042A6F9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|ARM64 = Release|ARM64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|ARM64.Build.0 = Debug|ARM64 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|Win32.ActiveCfg = Debug|Win32 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|Win32.Build.0 = Debug|Win32 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|x64.ActiveCfg = Debug|x64 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|x64.Build.0 = Debug|x64 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Release|ARM64.ActiveCfg = Release|ARM64 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Release|ARM64.Build.0 = Release|ARM64 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Release|Win32.ActiveCfg = Release|Win32 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Release|Win32.Build.0 = Release|Win32 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Release|x64.ActiveCfg = Release|x64 - {509B95C6-043E-4389-8351-77BDB042A6F9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B94274A0-9BB1-48E0-BED3-971CBCAF0052} - EndGlobalSection -EndGlobal diff --git a/PowerEditor/src/tools/NppShell/project/NppShell.vcxproj b/PowerEditor/src/tools/NppShell/project/NppShell.vcxproj deleted file mode 100644 index 411d84a6e..000000000 --- a/PowerEditor/src/tools/NppShell/project/NppShell.vcxproj +++ /dev/null @@ -1,336 +0,0 @@ - - - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - {509B95C6-043E-4389-8351-77BDB042A6F9} - NppShell - Win32Proj - 10.0 - - - - DynamicLibrary - v143 - Unicode - true - - - DynamicLibrary - v143 - Unicode - - - DynamicLibrary - v143 - Unicode - true - - - DynamicLibrary - v143 - Unicode - true - - - DynamicLibrary - v143 - Unicode - - - DynamicLibrary - v143 - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.28307.799 - - - .\..\build_$(Platform)\$(Configuration)\ - .\..\build_$(Platform)\$(Configuration)\ - true - - - .\..\build_$(Platform)\$(Configuration)\ - .\..\build_$(Platform)\$(Configuration)\ - true - - - .\..\build_$(Platform)\$(Configuration)\ - .\..\build_$(Platform)\$(Configuration)\ - true - - - .\..\build_$(Platform)\$(Configuration)\ - .\..\build_$(Platform)\$(Configuration)\ - false - - - .\..\build_$(Platform)\$(Configuration)\ - .\..\build_$(Platform)\$(Configuration)\ - false - - - .\..\build_$(Platform)\$(Configuration)\ - .\..\build_$(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - Level4 - false - EditAndContinue - - - shell32.lib;comctl32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - $(OutDir)..\$(ProjectName)_D.dll - ..\src\export.def - true - Windows - 0x1C000000 - false - - MachineX86 - - - - - X64 - - - Disabled - WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - Level4 - false - ProgramDatabase - - - _VC80_UPGRADE=0x0710;WIN64;%(PreprocessorDefinitions) - - - shell32.lib;comctl32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - $(OutDir)..\$(ProjectName)64_D.dll - ..\src\export.def - true - Windows - 0x1C000000 - false - - MachineX64 - - - - - - Disabled - WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level4 - false - ProgramDatabase - - - _VC80_UPGRADE=0x0710;WIN64;%(PreprocessorDefinitions) - - - shell32.lib;comctl32.lib;shlwapi.lib;msimg32.lib;gdi32.lib;advapi32.lib;ole32.lib;%(AdditionalDependencies) - $(OutDir)..\$(ProjectName)64_D.dll - ..\src\export.def - true - Windows - 0x1C000000 - false - - - - - - - Speed - WIN32;_WINDOWS;%(PreprocessorDefinitions) - true - - MultiThreaded - false - - Level4 - false - ProgramDatabase - - - shell32.lib;comctl32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - $(OutDir)..\$(ProjectName).dll - .\..\src\libs;%(AdditionalLibraryDirectories) - ..\src\export.def - false - Windows - true - true - false - - MachineX86 - - - - - X64 - - - Speed - WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - MultiThreadedDLL - false - - Level4 - false - ProgramDatabase - - - _VC80_UPGRADE=0x0710;WIN64;%(PreprocessorDefinitions) - - - shell32.lib;comctl32.lib;shlwapi.lib;msimg32.lib;%(AdditionalDependencies) - $(OutDir)..\$(ProjectName)64.dll - .\..\src\libs;%(AdditionalLibraryDirectories) - false - ..\src\export.def - false - Windows - true - true - false - - MachineX64 - - - - - - Speed - WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - - - Level4 - false - ProgramDatabase - - - _VC80_UPGRADE=0x0710;WIN64;%(PreprocessorDefinitions) - - - shell32.lib;comctl32.lib;shlwapi.lib;msimg32.lib;gdi32.lib;advapi32.lib;ole32.lib;%(AdditionalDependencies) - $(OutDir)..\$(ProjectName)64.dll - .\..\src\libs;%(AdditionalLibraryDirectories) - false - ..\src\export.def - false - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PowerEditor/src/tools/NppShell/src/Bitmap.cpp b/PowerEditor/src/tools/NppShell/src/Bitmap.cpp deleted file mode 100644 index cfa5c4f55..000000000 --- a/PowerEditor/src/tools/NppShell/src/Bitmap.cpp +++ /dev/null @@ -1,301 +0,0 @@ -//From: Visual Style Menus in MSDN - -#include "Bitmap.h" - -HMODULE hUxTheme = NULL; -FN_GetBufferedPaintBits pfnGetBufferedPaintBits = NULL; -FN_BeginBufferedPaint pfnBeginBufferedPaint = NULL; -FN_EndBufferedPaint pfnEndBufferedPaint = NULL; - -bool InitTheming() { - hUxTheme = ::LoadLibrary(TEXT("UxTheme.dll")); - if (hUxTheme == NULL) - return false; - pfnGetBufferedPaintBits = (FN_GetBufferedPaintBits)::GetProcAddress(hUxTheme, "GetBufferedPaintBits"); - pfnBeginBufferedPaint = (FN_BeginBufferedPaint)::GetProcAddress(hUxTheme, "BeginBufferedPaint"); - pfnEndBufferedPaint = (FN_EndBufferedPaint)::GetProcAddress(hUxTheme, "EndBufferedPaint"); - if ((pfnGetBufferedPaintBits == NULL) || (pfnBeginBufferedPaint == NULL) || (pfnEndBufferedPaint == NULL)) { - pfnGetBufferedPaintBits = NULL; - pfnBeginBufferedPaint = NULL; - pfnEndBufferedPaint = NULL; - return false; - } - - return true; -} - -bool DeinitTheming() { - pfnGetBufferedPaintBits = NULL; - pfnBeginBufferedPaint = NULL; - pfnEndBufferedPaint = NULL; - FreeLibrary(hUxTheme); - hUxTheme = NULL; - - return true; -} - -void InitBitmapInfo(BITMAPINFO *pbmi, ULONG cbInfo, LONG cx, LONG cy, WORD bpp) -{ - ZeroMemory(pbmi, cbInfo); - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biPlanes = 1; - pbmi->bmiHeader.biCompression = BI_RGB; - - pbmi->bmiHeader.biWidth = cx; - pbmi->bmiHeader.biHeight = cy; - pbmi->bmiHeader.biBitCount = bpp; -} - -HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, void **ppvBits, HBITMAP* phBmp) -{ - *phBmp = NULL; - - BITMAPINFO bmi; - InitBitmapInfo(&bmi, sizeof(bmi), psize->cx, psize->cy, 32); - - HDC hdcUsed = hdc ? hdc : GetDC(NULL); - if (hdcUsed) - { - *phBmp = CreateDIBSection(hdcUsed, &bmi, DIB_RGB_COLORS, ppvBits, NULL, 0); - if (hdc != hdcUsed) - { - ReleaseDC(NULL, hdcUsed); - } - } - return (NULL == *phBmp) ? E_OUTOFMEMORY : S_OK; -} - -HRESULT ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow) -{ - BITMAPINFO bmi; - InitBitmapInfo(&bmi, sizeof(bmi), sizImage.cx, sizImage.cy, 32); - - HRESULT hr = E_OUTOFMEMORY; - HANDLE hHeap = GetProcessHeap(); - void *pvBits = HeapAlloc(hHeap, 0, bmi.bmiHeader.biWidth * 4 * bmi.bmiHeader.biHeight); - if (pvBits) - { - hr = E_UNEXPECTED; - if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight) - { - ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth; - ARGB *pargbMask = static_cast(pvBits); - - for (ULONG y = bmi.bmiHeader.biHeight; y; --y) - { - for (ULONG x = bmi.bmiHeader.biWidth; x; --x) - { - if (*pargbMask++) - { - // transparent pixel - *pargb++ = 0; - } - else - { - // opaque pixel - *pargb++ |= 0xFF000000; - } - } - - pargb += cxDelta; - } - - hr = S_OK; - } - - HeapFree(hHeap, 0, pvBits); - } - - return hr; -} - -bool HasAlpha(ARGB *pargb, SIZE& sizImage, int cxRow) -{ - ULONG cxDelta = cxRow - sizImage.cx; - for (ULONG y = sizImage.cy; y; --y) - { - for (ULONG x = sizImage.cx; x; --x) - { - if (*pargb++ & 0xFF000000) - { - return true; - } - } - - pargb += cxDelta; - } - - return false; -} - -HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon) -{ - RGBQUAD *prgbQuad; - int cxRow; - HRESULT hr = pfnGetBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow); - if (SUCCEEDED(hr)) - { - ARGB *pargb = reinterpret_cast(prgbQuad); - if (!HasAlpha(pargb, sizIcon, cxRow)) - { - ICONINFO info; - if (GetIconInfo(hicon, &info)) - { - if (info.hbmMask) - { - hr = ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow); - } - - DeleteObject(info.hbmColor); - DeleteObject(info.hbmMask); - } - } - } - - return hr; -} - -HBITMAP IconToBitmapPARGB32(HICON hIcon, DWORD cx, DWORD cy) -{ - HRESULT hr = E_OUTOFMEMORY; - HBITMAP hBmp = NULL; - - if(!hIcon) - return NULL; - - SIZE sizIcon; - sizIcon.cx = cx; - sizIcon.cy = cy; - - RECT rcIcon; - SetRect(&rcIcon, 0, 0, sizIcon.cx, sizIcon.cy); - - HDC hdcDest = CreateCompatibleDC(NULL); - if(hdcDest) { - hr = Create32BitHBITMAP(hdcDest, &sizIcon, NULL, &hBmp); - if(SUCCEEDED(hr)) { - hr = E_FAIL; - - HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcDest, hBmp); - if(hbmpOld) { - BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; - BP_PAINTPARAMS paintParams = {0, 0, 0, 0}; - paintParams.cbSize = sizeof(paintParams); - paintParams.dwFlags = BPPF_ERASE; - paintParams.pBlendFunction = &bfAlpha; - - HDC hdcBuffer; - HPAINTBUFFER hPaintBuffer = pfnBeginBufferedPaint(hdcDest, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer); - if(hPaintBuffer) { - if(DrawIconEx(hdcBuffer, 0, 0, hIcon, sizIcon.cx, sizIcon.cy, 0, NULL, DI_NORMAL)) { - // If icon did not have an alpha channel, we need to convert buffer to PARGB. - hr = ConvertBufferToPARGB32(hPaintBuffer, hdcDest, hIcon, sizIcon); - } - - // This will write the buffer contents to the destination bitmap. - pfnEndBufferedPaint(hPaintBuffer, TRUE); - } - SelectObject(hdcDest, hbmpOld); - } - } - DeleteDC(hdcDest); - } - - DestroyIcon(hIcon); - if(SUCCEEDED(hr)) { - return hBmp; - } - DeleteObject(hBmp); - return NULL; -} -/* -// LoadIconEx: Loads an icon with a specific size and color depth. This function -// will NOT try to strech or take an icon of another color depth if none is -// present. -HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpszName, int cx, int cy, int depth) -{ - HRSRC hRsrcIconGroup; - - // Load the icon group of the desired icon - if (!(hRsrcIconGroup=FindResource(hInstance,lpszName,RT_GROUP_ICON))) - return NULL; - - // Look for the specified color depth - - // Load the resource - - GRPICONDIR* pGrpIconDir; - HRSRC hGlobalIconDir; - - if (!(hGlobalIconDir=(HRSRC)LoadResource(hInstance,hRsrcIconGroup))) - return NULL; - - // Lock the resource - - if (!(pGrpIconDir=(GRPICONDIR*) LockResource(hGlobalIconDir))) - return NULL; - - // Cycle through all icon images trying to find the one we're looking for - - int i; - BOOL bFound=FALSE; - - // In case of 8bpp or higher, the bColorCount of the structure is 0, and we - // must find our icon with the wPlanes and wBitCount. So if the requested - // number of colors is >=256, we calculate using those fields - - int bestIndex = -1; - int bestDepth = -1; //depth of icon either has to be equal (best match) or larger, or no best icon found - int bestSize = -1; //Size either has to be equal (best match) or smaller - - int nrColors = 1 << depth; - - for (i=0;iidCount;i++) - { - GRPICONDIRENTRY & entry = pGrpIconDir->idEntries[i]; - int iconColors = (entry.bColorCount==0)?1 << (entry.wPlanes*entry.wBitCount) : entry.bColorCount; - if (iconColors < bestDepth); - - if ((entry.bWidth==cx) && (entry.bHeight==cy)) // Do the size match? - { - bFound = TRUE; // Yes, it matches - break; - } - } - - if (!bFound) - return NULL; // No icon was found matching the specs - - // Icon was found! i contains the index to the GRPICONDIR structure in the - // icon group. Find the ID of the icon - - int nID; - - nID=pGrpIconDir->idEntries[i].nID; - - // Now, find the actual icon resource - - HRSRC hRsrcIcon; - HRSRC hGlobalIcon; - void* pIconBits; - - if (!(hRsrcIcon=FindResource(hInstance,MAKEINTRESOURCE(nID),RT_ICON))) - return NULL; - - if (!(hGlobalIcon=(HRSRC)LoadResource(hInstance,hRsrcIcon))) - return NULL; - - if (!(pIconBits=LockResource(hGlobalIcon))) - return NULL; - - // Now, use CreateIconFromResourceEx to create the actual HICON - - return CreateIconFromResourceEx( - (unsigned char*) pIconBits, // Pointer to icon data - pGrpIconDir->idEntries[i].dwBytesInRes, // Size of icon data - TRUE, // TRUE to create an icon, not a cursor - 0x00030000, // Version number. MSDN says to put that number - cx, cy, // Width and height - 0); // Flags (none) -} -*/ diff --git a/PowerEditor/src/tools/NppShell/src/Bitmap.h b/PowerEditor/src/tools/NppShell/src/Bitmap.h deleted file mode 100644 index da1f1faee..000000000 --- a/PowerEditor/src/tools/NppShell/src/Bitmap.h +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include - -#ifndef BPPF_ERASE -#define BPPF_ERASE 1 -#endif - -typedef DWORD ARGB; -typedef HRESULT (WINAPI *FN_GetBufferedPaintBits) (HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer, int *pcxRow); -typedef HPAINTBUFFER (WINAPI *FN_BeginBufferedPaint) (HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc); -typedef HRESULT (WINAPI *FN_EndBufferedPaint) (HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget); - -bool InitTheming(); -bool DeinitTheming(); - -void InitBitmapInfo(BITMAPINFO *pbmi, ULONG cbInfo, LONG cx, LONG cy, WORD bpp); -HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, void **ppvBits, HBITMAP* phBmp); -HRESULT ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow); -bool HasAlpha(ARGB *pargb, SIZE& sizImage, int cxRow); -HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon); -HBITMAP IconToBitmapPARGB32(HICON hIcon, DWORD cx, DWORD cy); - -typedef struct -{ - BYTE bWidth; // Width, in pixels, of the image - BYTE bHeight; // Height, in pixels, of the image - BYTE bColorCount; // Number of colors in image (0 if >=8bpp) - BYTE bReserved; // Reserved - WORD wPlanes; // Color Planes - WORD wBitCount; // Bits per pixel - DWORD dwBytesInRes; // how many bytes in this resource? - WORD nID; // the ID -} GRPICONDIRENTRY, *LPGRPICONDIRENTRY; - -typedef struct -{ - WORD idReserved; // Reserved (must be 0) - WORD idType; // Resource type (1 for icons) - WORD idCount; // How many images? - GRPICONDIRENTRY idEntries[1]; // The entries for each image -} GRPICONDIR, *LPGRPICONDIR; - - - -HICON LoadIconEx(HINSTANCE hInst, LPCTSTR lpszName, int cz, int cy, int depth); diff --git a/PowerEditor/src/tools/NppShell/src/NppShell.cpp b/PowerEditor/src/tools/NppShell/src/NppShell.cpp deleted file mode 100755 index 4a4ff9e66..000000000 --- a/PowerEditor/src/tools/NppShell/src/NppShell.cpp +++ /dev/null @@ -1,1099 +0,0 @@ -#include "NppShell.h" -#include "Bitmap.h" -#include "resource.h" -#include -#include - -#ifndef RGBA -#define RGBA(r,g,b,a) ((COLORREF)( (((DWORD)(BYTE)(a))<<24) | RGB(r,g,b) )) -#endif - - - -//--------------------------------------------------------------------------- -// Global variables -//--------------------------------------------------------------------------- -UINT _cRef = 0; // COM Reference count. -HINSTANCE _hModule = NULL; // DLL Module. - -//Some global default values for registering the DLL - -//Menu -TCHAR szNppName[] = TEXT("notepad++.exe"); -TCHAR szDefaultMenutext[] = TEXT("Edit with &Notepad++"); - -#ifdef WIN64 -TCHAR szShellExtensionTitle[] = TEXT("ANotepad++64"); -TCHAR szShellExtensionKey[] = TEXT("*\\shellex\\ContextMenuHandlers\\ANotepad++64"); -#else -TCHAR szShellExtensionTitle[] = TEXT("ANotepad++"); -TCHAR szShellExtensionKey[] = TEXT("*\\shellex\\ContextMenuHandlers\\ANotepad++"); -#endif - -#define szHelpTextA "Edits the selected file(s) with Notepad++" -#define szHelpTextW L"Edits the selected file(s) with Notepad++" -TCHAR szMenuTitle[TITLE_SIZE]; -TCHAR szDefaultCustomcommand[] = TEXT(""); -//Icon -DWORD isDynamic = 1; -DWORD maxText = 25; -DWORD showIcon = 1; - -//Forward function declarations -extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved); -STDAPI DllRegisterServer(void); -STDAPI DllUnregisterServer(void); - -BOOL RegisterServer(); -BOOL UnregisterServer(); -void MsgBox(LPCTSTR lpszMsg); -void MsgBoxError(LPCTSTR lpszMsg); -BOOL CheckNpp(LPCTSTR path); -intptr_t CALLBACK DlgProcSettings(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -void InvalidateIcon(HICON * iconSmall, HICON * iconLarge); - -#ifdef UNICODE -#define _ttoi _wtoi -#else -#define _ttoi atoi -#endif - - - -//Types -struct DOREGSTRUCT { - HKEY hRootKey; - LPCTSTR szSubKey; - LPCTSTR lpszValueName; - DWORD type; - LPCTSTR szData; -}; - -//--------------------------------------------------------------------------- -// DllMain -//--------------------------------------------------------------------------- -int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { - if (dwReason == DLL_PROCESS_ATTACH) { - _hModule = hInstance; - } - return TRUE; -} - -//--------------------------------------------------------------------------- -// DllCanUnloadNow -//--------------------------------------------------------------------------- -STDAPI DllCanUnloadNow(void) { - return (_cRef == 0 ? S_OK : S_FALSE); -} - -//--------------------------------------------------------------------------- -// DllGetClassObject -//--------------------------------------------------------------------------- -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut) { - *ppvOut = NULL; - if (IsEqualIID(rclsid, CLSID_ShellExtension)) { - CShellExtClassFactory *pcf = new CShellExtClassFactory; - return pcf->QueryInterface(riid, ppvOut); - } - return CLASS_E_CLASSNOTAVAILABLE; -} - -//--------------------------------------------------------------------------- -// DllRegisterServer -//--------------------------------------------------------------------------- -STDAPI DllRegisterServer(void) { - return (RegisterServer() ? S_OK : E_FAIL); -} - -//--------------------------------------------------------------------------- -// DllUnregisterServer -//--------------------------------------------------------------------------- -STDAPI DllUnregisterServer(void) { - return (UnregisterServer() ? S_OK : E_FAIL); -} - -STDAPI DllInstall(BOOL bInstall, LPCWSTR /*pszCmdLine*/) { - if (bInstall) { - DialogBox(_hModule, MAKEINTRESOURCE(IDD_DIALOG_SETTINGS), NULL, (DLGPROC)&DlgProcSettings); - return S_OK; - } else { - MsgBoxError(TEXT("Uninstalling not supported, use DllUnregisterServer instead")); - return E_NOTIMPL; - } -} - -//--------------------------------------------------------------------------- -// RegisterServer -// Create registry entries and setup the shell extension -//--------------------------------------------------------------------------- -BOOL RegisterServer() { - int i; - HKEY hKey; - LRESULT lResult; - DWORD dwDisp; - TCHAR szSubKey[MAX_PATH]; - TCHAR szModule[MAX_PATH]; - TCHAR szDefaultPath[MAX_PATH]; - - GetModuleFileName(_hModule, szDefaultPath, MAX_PATH); - TCHAR* pDest = StrRChr(szDefaultPath, NULL, TEXT('\\')); - pDest++; - pDest[0] = 0; - lstrcat(szDefaultPath, szNppName); - - if (!CheckNpp(szDefaultPath)) { - MsgBoxError(TEXT("To register the Notepad++ shell extension properly,\r\nplace NppShell.dll in the same directory as the Notepad++ executable.")); - //return FALSE; - } - - //get this app's path and file name - GetModuleFileName(_hModule, szModule, MAX_PATH); - - static DOREGSTRUCT ClsidEntries[] = { - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, REG_SZ, szShellExtensionTitle}, - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, REG_SZ, szModule}, - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), TEXT("ThreadingModel"), REG_SZ, TEXT("Apartment")}, - - //Settings - // Context menu - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Title"), REG_SZ, szDefaultMenutext}, - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Path"), REG_SZ, szDefaultPath}, - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Custom"), REG_SZ, szDefaultCustomcommand}, - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("ShowIcon"), REG_DWORD, (LPTSTR)&showIcon}, - // Icon - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Dynamic"), REG_DWORD, (LPTSTR)&isDynamic}, - {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Maxtext"), REG_DWORD, (LPTSTR)&maxText}, - - //Registration - // Context menu - {HKEY_CLASSES_ROOT, szShellExtensionKey, NULL, REG_SZ, szGUID}, - // Icon - //{HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), NULL, REG_SZ, szGUID}, - - {NULL, NULL, NULL, REG_SZ, NULL} - }; - - // First clear any old entries - UnregisterServer(); - - // Register the CLSID entries - for(i = 0; ClsidEntries[i].hRootKey; i++) { - wsprintf(szSubKey, ClsidEntries[i].szSubKey, szGUID); - lResult = RegCreateKeyEx(ClsidEntries[i].hRootKey, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp); - if (NOERROR == lResult) { - TCHAR szData[MAX_PATH]; - // If necessary, create the value string - if (ClsidEntries[i].type == REG_SZ) { - wsprintf(szData, ClsidEntries[i].szData, szModule); - lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR)); - } else { - lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)ClsidEntries[i].szData, sizeof(DWORD)); - } - RegCloseKey(hKey); - } - else - return FALSE; - } - return TRUE; -} - -//--------------------------------------------------------------------------- -// UnregisterServer -//--------------------------------------------------------------------------- -BOOL UnregisterServer() { - TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE]; - - RegDeleteKey(HKEY_CLASSES_ROOT, szShellExtensionKey); - - wsprintf(szKeyTemp, TEXT("Notepad++_file\\shellex\\IconHandler")); - RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp); - wsprintf(szKeyTemp, TEXT("Notepad++_file\\shellex")); - RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp); - - wsprintf(szKeyTemp, TEXT("CLSID\\%s\\InprocServer32"), szGUID); - RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp); - wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID); - RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp); - wsprintf(szKeyTemp, TEXT("CLSID\\%s"), szGUID); - RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp); - - return TRUE; -} - -//--------------------------------------------------------------------------- -// MsgBox -//--------------------------------------------------------------------------- -void MsgBox(LPCTSTR lpszMsg) { - MessageBox(NULL, - lpszMsg, - TEXT("Notepad++ Extension"), - MB_OK); -} - -//--------------------------------------------------------------------------- -// MsgBoxError -//--------------------------------------------------------------------------- -void MsgBoxError(LPCTSTR lpszMsg) { - MessageBox(NULL, - lpszMsg, - TEXT("Notepad++ Extension: Error"), - MB_OK | MB_ICONWARNING); -} - -//--------------------------------------------------------------------------- -// CheckNpp -// Check if the shell handler resides in the same directory as notepad++ -//--------------------------------------------------------------------------- -BOOL CheckNpp(LPCTSTR path) { - WIN32_FIND_DATA fd; - HANDLE findHandle; - - findHandle = FindFirstFile(path, &fd); - if (findHandle == INVALID_HANDLE_VALUE) { - return FALSE; - } else { - FindClose(findHandle); - } - return TRUE; -} - -intptr_t CALLBACK DlgProcSettings(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static TCHAR customCommand[MAX_PATH] = {0}; - static TCHAR customText[TITLE_SIZE] = {0}; - static TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE]; - - static DWORD showMenu = 2; //0 off, 1 on, 2 unknown - static DWORD useMenuIcon = 1; // 0 off, otherwise on - - HKEY settingKey; - LONG result; - DWORD size = 0; - - switch(uMsg) { - case WM_INITDIALOG: { - wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID); - result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey); - if (result == ERROR_SUCCESS) { - size = sizeof(TCHAR)*TITLE_SIZE; - result = RegQueryValueEx(settingKey, TEXT("Title"), NULL, NULL, (LPBYTE)(customText), &size); - if (result != ERROR_SUCCESS) { - lstrcpyn(customText, szDefaultMenutext, TITLE_SIZE); - } - - size = sizeof(TCHAR)*MAX_PATH; - result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(customCommand), &size); - if (result != ERROR_SUCCESS) { - lstrcpyn(customCommand, TEXT(""), MAX_PATH); - } - - size = sizeof(DWORD); - result = RegQueryValueEx(settingKey, TEXT("Dynamic"), NULL, NULL, (BYTE*)(&isDynamic), &size); - if (result != ERROR_SUCCESS) { - isDynamic = 1; - } - - size = sizeof(DWORD); - result = RegQueryValueEx(settingKey, TEXT("ShowIcon"), NULL, NULL, (BYTE*)(&useMenuIcon), &size); - if (result != ERROR_SUCCESS) { - useMenuIcon = 1; - } - - RegCloseKey(settingKey); - } - - Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_USECONTEXT), BST_INDETERMINATE); - Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_USEICON), BST_INDETERMINATE); - - Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_CONTEXTICON), useMenuIcon?BST_CHECKED:BST_UNCHECKED); - Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_ISDYNAMIC), isDynamic?BST_CHECKED:BST_UNCHECKED); - - SetDlgItemText(hwndDlg, IDC_EDIT_MENU, customText); - SetDlgItemText(hwndDlg, IDC_EDIT_COMMAND, customCommand); - - return TRUE; - break; } - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case IDOK: { - //Store settings - GetDlgItemText(hwndDlg, IDC_EDIT_MENU, customText, TITLE_SIZE); - GetDlgItemText(hwndDlg, IDC_EDIT_COMMAND, customCommand, MAX_PATH); - int textLen = lstrlen(customText); - int commandLen = lstrlen(customCommand); - - wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID); - result = RegCreateKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL); - if (result == ERROR_SUCCESS) { - - result = RegSetValueEx(settingKey, TEXT("Title"), 0,REG_SZ, (LPBYTE)customText, (textLen+1)*sizeof(TCHAR)); - result = RegSetValueEx(settingKey, TEXT("Custom"), 0,REG_SZ, (LPBYTE)customCommand, (commandLen+1)*sizeof(TCHAR)); - - result = RegSetValueEx(settingKey, TEXT("Dynamic"), 0, REG_DWORD, (LPBYTE)&isDynamic, sizeof(DWORD)); - result = RegSetValueEx(settingKey, TEXT("ShowIcon"), 0, REG_DWORD, (LPBYTE)&useMenuIcon, sizeof(DWORD)); - - RegCloseKey(settingKey); - } - - if (showMenu == 1) { - result = RegCreateKeyEx(HKEY_CLASSES_ROOT, szShellExtensionKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL); - if (result == ERROR_SUCCESS) { - result = RegSetValueEx(settingKey, NULL, 0,REG_SZ, (LPBYTE)szGUID, (lstrlen(szGUID)+1)*sizeof(TCHAR)); - RegCloseKey(settingKey); - } - } else if (showMenu == 0) { - RegDeleteKey(HKEY_CLASSES_ROOT, szShellExtensionKey); - } - - if (showIcon == 1) { - result = RegCreateKeyEx(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL); - if (result == ERROR_SUCCESS) { - result = RegSetValueEx(settingKey, NULL, 0,REG_SZ, (LPBYTE)szGUID, (lstrlen(szGUID)+1)*sizeof(TCHAR)); - RegCloseKey(settingKey); - } - } else if (showIcon == 0) { - RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler")); - RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex")); - } - - PostMessage(hwndDlg, WM_CLOSE, 0, 0); - break; } - case IDC_CHECK_USECONTEXT: { - int state = Button_GetCheck((HWND)lParam); - if (state == BST_CHECKED) - showMenu = 1; - else if (state == BST_UNCHECKED) - showMenu = 0; - else - showMenu = 2; - break; } - case IDC_CHECK_USEICON: { - int state = Button_GetCheck((HWND)lParam); - if (state == BST_CHECKED) - showIcon = 1; - else if (state == BST_UNCHECKED) - showIcon = 0; - else - showIcon = 2; - break; } - case IDC_CHECK_CONTEXTICON: { - int state = Button_GetCheck((HWND)lParam); - if (state == BST_CHECKED) - useMenuIcon = 1; - else - useMenuIcon = 0; - break; } - case IDC_CHECK_ISDYNAMIC: { - int state = Button_GetCheck((HWND)lParam); - if (state == BST_CHECKED) - isDynamic = 1; - else - isDynamic = 0; - break; } - default: - break; - } - - return TRUE; - break; } - case WM_CLOSE: { - EndDialog(hwndDlg, 0); - return TRUE; - break; } - default: - break; - } - - return FALSE; -} - -// --- CShellExtClassFactory --- -CShellExtClassFactory::CShellExtClassFactory() : - m_cRef(0L) -{ - _cRef++; -} - -CShellExtClassFactory::~CShellExtClassFactory() { - _cRef--; -} - -// *** IUnknown methods *** -STDMETHODIMP CShellExtClassFactory::QueryInterface(REFIID riid, LPVOID FAR *ppv) { - *ppv = NULL; - if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) { - *ppv = (LPCLASSFACTORY)this; - AddRef(); - return NOERROR; - } - return E_NOINTERFACE; -} - -STDMETHODIMP_(ULONG) CShellExtClassFactory::AddRef() { - return ++m_cRef; -} - -STDMETHODIMP_(ULONG) CShellExtClassFactory::Release() -{ - if (--m_cRef) - return m_cRef; - delete this; - return 0L; -} - -// *** IClassFactory methods *** -STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) { - *ppvObj = NULL; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - CShellExt * pShellExt = new CShellExt(); - if (!pShellExt) - return E_OUTOFMEMORY; - return pShellExt->QueryInterface(riid, ppvObj); -} - -STDMETHODIMP CShellExtClassFactory::LockServer(BOOL /*fLock*/) { - return NOERROR; -} - -// --- CShellExt --- -CShellExt::CShellExt() : - m_cRef(0L), - m_cbFiles(0), - m_pDataObj(NULL), - m_menuID(0), - m_hMenu(NULL), - m_showIcon(true), - m_useCustom(false), - m_nameLength(0), - m_nameMaxLength(maxText), - m_isDynamic(false), - m_winVer(0), - m_hBitmap(NULL) -{ - TCHAR szKeyTemp [MAX_PATH + GUID_STRING_SIZE]; - ZeroMemory(&m_stgMedium, sizeof(m_stgMedium)); - _cRef++; - - GetModuleFileName(_hModule, m_szModule, MAX_PATH); - - OSVERSIONINFOEX inf; - ZeroMemory(&inf, sizeof(OSVERSIONINFOEX)); - inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - GetVersionEx((OSVERSIONINFO *)&inf); - m_winVer = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion); - - if (m_winVer >= WINVER_VISTA) { - InitTheming(); - } - - HKEY settingKey; - LONG result; - DWORD size = 0; - DWORD dyn = 0, siz = 0, showicon = 0; - - wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID); - result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey); - if (result == ERROR_SUCCESS) { - size = sizeof(TCHAR)*TITLE_SIZE; - result = RegQueryValueEx(settingKey, TEXT("Title"), NULL, NULL, (LPBYTE)(m_szMenuTitle), &size); - if (result != ERROR_SUCCESS) { - lstrcpyn(m_szMenuTitle, szDefaultMenutext, TITLE_SIZE); - } - - size = sizeof(DWORD); - result = RegQueryValueEx(settingKey, TEXT("Dynamic"), NULL, NULL, (BYTE*)(&dyn), &size); - if (result == ERROR_SUCCESS && dyn != 0) { - m_isDynamic = true; - } - - size = sizeof(DWORD); - result = RegQueryValueEx(settingKey, TEXT("Maxtext"), NULL, NULL, (BYTE*)(&siz), &size); - if (result == ERROR_SUCCESS) { - m_nameMaxLength = std::max((DWORD)0,siz); - } - - size = sizeof(DWORD); - result = RegQueryValueEx(settingKey, TEXT("ShowIcon"), NULL, NULL, (BYTE*)(&showicon), &size); - if (result == ERROR_SUCCESS) { - m_showIcon = (showicon != 0); - } - - result = RegQueryValueEx(settingKey, TEXT("CustomIcon"), NULL, NULL, NULL, NULL); - if (result == ERROR_SUCCESS) { - m_useCustom = true; - size = MAX_PATH; - RegQueryValueEx(settingKey, TEXT("CustomIcon"), NULL, NULL, (BYTE*)m_szCustomPath, &size); - } - - RegCloseKey(settingKey); - } -} - -CShellExt::~CShellExt() { - if (m_winVer >= WINVER_VISTA) { - DeinitTheming(); - } - - if (m_hBitmap != NULL && m_hBitmap != HBMMENU_CALLBACK) - DeleteBitmap(m_hBitmap); - - if (m_pDataObj) - m_pDataObj->Release(); - _cRef--; -} -// *** IUnknown methods *** -STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv) { - *ppv = NULL; - if (IsEqualIID(riid, IID_IUnknown)) { - //*ppv = (LPUNKNOWN)this; - *ppv = (LPSHELLEXTINIT)this; - } else if (IsEqualIID(riid, IID_IShellExtInit)) { - *ppv = (LPSHELLEXTINIT)this; - } else if (IsEqualIID(riid, IID_IContextMenu)) { - *ppv = (LPCONTEXTMENU)this; - } else if (IsEqualIID(riid, IID_IContextMenu2)) { - *ppv = (LPCONTEXTMENU2)this; - } else if (IsEqualIID(riid, IID_IContextMenu3)) { - *ppv = (LPCONTEXTMENU3)this; - } else if (IsEqualIID(riid, IID_IPersistFile)) { - *ppv = (LPPERSISTFILE)this; - } else if (IsEqualIID(riid, IID_IExtractIcon)) { - *ppv = (LPEXTRACTICON)this; - } - if (*ppv) { - AddRef(); - return NOERROR; - } - return E_NOINTERFACE; -} - -STDMETHODIMP_(ULONG) CShellExt::AddRef() { - return ++m_cRef; -} - -STDMETHODIMP_(ULONG) CShellExt::Release() { - if (--m_cRef) - return m_cRef; - delete this; - return 0L; -} - -// *** IShellExtInit methods *** -STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST /*pIDFolder*/, LPDATAOBJECT pDataObj, HKEY /*hRegKey*/) { - if (m_pDataObj) { - m_pDataObj->Release(); - m_pDataObj = NULL; - } - if (pDataObj) { - m_pDataObj = pDataObj; - pDataObj->AddRef(); - } - return NOERROR; -} - -// *** IContextMenu methods *** -STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) { - UINT idCmd = idCmdFirst; - - FORMATETC fmte = { - CF_HDROP, - (DVTARGETDEVICE FAR *)NULL, - DVASPECT_CONTENT, - -1, - TYMED_HGLOBAL - }; - - HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium); - - if (SUCCEEDED(hres)) { - if (m_stgMedium.hGlobal) - m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0); - } - - UINT nIndex = indexMenu++; - - InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, m_szMenuTitle); - - - if (m_showIcon) { - HBITMAP icon = NULL; - if (m_winVer >= WINVER_VISTA) { - icon = NULL; - HICON hicon; - DWORD menuIconWidth = GetSystemMetrics(SM_CXMENUCHECK); - DWORD menuIconHeight = GetSystemMetrics(SM_CYMENUCHECK); - HRESULT hr = LoadShellIcon(menuIconWidth, menuIconHeight, &hicon); - if (SUCCEEDED(hr)) { - icon = IconToBitmapPARGB32(hicon, menuIconWidth, menuIconHeight); - DestroyIcon(hicon); - } - } else { - icon = HBMMENU_CALLBACK; - } - - if (icon != NULL) { - MENUITEMINFO mii; - ZeroMemory(&mii, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_BITMAP; - mii.hbmpItem = icon; - //mii.hbmpChecked = icon; - //mii.hbmpUnchecked = icon; - - SetMenuItemInfo(hMenu, nIndex, MF_BYPOSITION, &mii); - - if (m_winVer >= WINVER_VISTA) { - MENUINFO MenuInfo; - MenuInfo.cbSize = sizeof(MenuInfo); - MenuInfo.fMask = MIM_STYLE; - MenuInfo.dwStyle = MNS_CHECKORBMP; - - SetMenuInfo(hMenu, &MenuInfo); - } - - } - m_hBitmap = icon; - } - - m_hMenu = hMenu; - m_menuID = idCmd; - - return ResultFromShort(idCmd-idCmdFirst); -} - -STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) { - HRESULT hr = E_INVALIDARG; - - if (!HIWORD(lpcmi->lpVerb)) { - UINT idCmd = LOWORD(lpcmi->lpVerb); - switch(idCmd) { - case 0: - hr = InvokeNPP(lpcmi->hwnd, lpcmi->lpDirectory, lpcmi->lpVerb, lpcmi->lpParameters, lpcmi->nShow); - break; - default: - break; - } - } - return hr; -} - -STDMETHODIMP CShellExt::GetCommandString(UINT_PTR, UINT uFlags, UINT FAR *, LPSTR pszName, UINT cchMax) { - LPWSTR wBuffer = (LPWSTR) pszName; - if (uFlags == GCS_HELPTEXTA) { - lstrcpynA(pszName, szHelpTextA, cchMax); - return S_OK; - } else if (uFlags == GCS_HELPTEXTW) { - lstrcpynW(wBuffer, szHelpTextW, cchMax); - return S_OK; - } - return E_NOTIMPL; -} - -STDMETHODIMP CShellExt::HandleMenuMsg2(UINT uMsg, WPARAM /*wParam*/, LPARAM lParam, LRESULT *plResult) { - - //Setup popup menu stuff (ownerdrawn) - DWORD menuIconWidth = GetSystemMetrics(SM_CXMENUCHECK); - DWORD menuIconHeight = GetSystemMetrics(SM_CYMENUCHECK); - DWORD menuIconPadding = 2; //+1 pixels on each side, is this fixed? - - switch(uMsg) { - case WM_MEASUREITEM: { //for owner drawn menu - MEASUREITEMSTRUCT * lpdis = (MEASUREITEMSTRUCT*) lParam; - - if (lpdis == NULL)// || lpdis->itemID != m_menuID) - break; - - if (m_showIcon) { - lpdis->itemWidth = 0; //0 seems to work for 98 and up - if (lpdis->itemHeight < menuIconHeight) - lpdis->itemHeight = menuIconHeight; - } - - if (plResult) - *plResult = TRUE; - break; } - case WM_DRAWITEM: { //for owner drawn menu - //Assumes proper font already been set - DRAWITEMSTRUCT * lpdis = (DRAWITEMSTRUCT*) lParam; - if ((lpdis == NULL) || (lpdis->CtlType != ODT_MENU)) - break; - - if (m_showIcon) { - HICON nppIcon = NULL; - - HRESULT hr = LoadShellIcon(menuIconWidth, menuIconHeight, &nppIcon); - - if (SUCCEEDED(hr)) { - DrawIconEx(lpdis->hDC, menuIconPadding, menuIconPadding, nppIcon, menuIconWidth, menuIconHeight, 0, NULL, DI_NORMAL); - DestroyIcon(nppIcon); - } - } - - if (plResult) - *plResult = TRUE; - - break; } - default: - break; - } - - return S_OK; -} - -// *** IPersistFile methods *** -HRESULT STDMETHODCALLTYPE CShellExt::Load(LPCOLESTR pszFileName, DWORD /*dwMode*/) { - LPTSTR file[MAX_PATH]; -#ifdef UNICODE - lstrcpyn((LPWSTR)file, pszFileName, MAX_PATH); -#else - WideCharToMultiByte(CP_ACP, 0, pszFileName, -1, (LPSTR)file, MAX_PATH, NULL, NULL); -#endif - m_szFilePath[0] = 0; - - LPTSTR ext = PathFindExtension((LPTSTR)file); - if (ext[0] == '.') { - ext++; - } - int copySize = std::min(m_nameMaxLength+1, MAX_PATH); //+1 to take zero terminator in account - lstrcpyn(m_szFilePath, ext, copySize); - m_nameLength = lstrlen(m_szFilePath); - CharUpperBuff(m_szFilePath, m_nameLength); - return S_OK; -} - -// *** IExtractIcon methods *** -STDMETHODIMP CShellExt::GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax, int * piIndex, UINT * pwFlags) { - *pwFlags = 0; - if (uFlags & GIL_DEFAULTICON || m_szFilePath[0] == 0 || !m_isDynamic) { //return regular N++ icon if requested OR the extension is bad OR static icon - if (!m_useCustom) { - lstrcpyn(szIconFile, m_szModule, cchMax); - *piIndex = 0; - } else { - lstrcpyn(szIconFile, m_szCustomPath, cchMax); - *piIndex = 0; - } - return S_OK; - } - - if(cchMax > 0) { - lstrcpyn(szIconFile, TEXT("NppShellIcon"), cchMax); - int len = lstrlen(szIconFile); - lstrcpyn(szIconFile, m_szFilePath, cchMax-len); - } - *piIndex = 0; - *pwFlags |= GIL_NOTFILENAME;//|GIL_DONTCACHE|GIL_PERINSTANCE; - - return S_OK; -} - -STDMETHODIMP CShellExt::Extract(LPCTSTR /*pszFile*/, UINT /*nIconIndex*/, HICON * phiconLarge, HICON * phiconSmall, UINT nIconSize) { - WORD sizeSmall = HIWORD(nIconSize); - WORD sizeLarge = LOWORD(nIconSize); - ICONINFO iconinfo; - BOOL res; - HRESULT hrSmall = S_OK, hrLarge = S_OK; - - if (phiconSmall) - hrSmall = LoadShellIcon(sizeSmall, sizeSmall, phiconSmall); - if (phiconLarge) - hrLarge = LoadShellIcon(sizeLarge, sizeLarge, phiconLarge); - - if (FAILED(hrSmall) || FAILED(hrLarge)) { - InvalidateIcon(phiconSmall, phiconLarge); - return S_FALSE; - } - - if (!m_isDynamic || !phiconLarge || sizeLarge < 32) //No modifications required - return S_OK; - - HDC dcEditColor, dcEditMask, dcEditTemp; - HFONT font; - HBRUSH brush; - HPEN pen; - BITMAPINFO bmi; - HBITMAP hbm; - LPDWORD pPix; - - res = GetIconInfo(*phiconLarge, &iconinfo); - if (!res) - return S_OK; //abort, the icon is still valid - - res = DestroyIcon(*phiconLarge); - if (!res) - return S_OK; - else - *phiconLarge = NULL; - - dcEditColor = CreateCompatibleDC(GetDC(0)); - dcEditMask = CreateCompatibleDC(GetDC(0)); - dcEditTemp = CreateCompatibleDC(GetDC(0)); - - // Create temp bitmap to render rectangle to - ZeroMemory(&bmi, sizeof(bmi)); - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = sizeLarge; - bmi.bmiHeader.biHeight = sizeLarge; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = 32; - bmi.bmiHeader.biCompression = BI_RGB; - hbm = CreateDIBSection(dcEditTemp, &bmi, DIB_RGB_COLORS, (VOID**)&pPix, NULL, 0); - memset(pPix, 0x00FFFFFF, sizeof(DWORD)*sizeLarge*sizeLarge); //initialize to white pixels, no alpha - - SelectObject(dcEditColor, iconinfo.hbmColor); - SelectObject(dcEditMask, iconinfo.hbmMask); - SelectObject(dcEditTemp, hbm); - - LONG calSize = (LONG)(sizeLarge*2/5); - - LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}}; - lf.lfHeight = calSize; - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = DEFAULT_CHARSET; - lstrcpyn(lf.lfFaceName, TEXT("Courier New"), LF_FACESIZE); - RECT rectText = {0, 0, 0, 0}; - RECT rectBox = {0, 0, 0, 0}; - COLORREF backGround = RGB(1, 1, 60); - COLORREF textColor = RGB(250,250,250); - - font = CreateFontIndirect(&lf); - brush = CreateSolidBrush(backGround); - pen = CreatePen(PS_NULL, 0, backGround); - SelectObject(dcEditTemp, font); - SelectObject(dcEditTemp, brush); - SelectObject(dcEditTemp, pen); - SetBkMode(dcEditTemp, TRANSPARENT); //dont clear background when drawing text - SetBkColor(dcEditTemp, backGround); - SetTextColor(dcEditTemp, textColor); - - //Calculate size of the displayed string - SIZE stringSize; - GetTextExtentPoint32(dcEditTemp, m_szFilePath, m_nameLength, &stringSize); - stringSize.cx = std::min(stringSize.cx, (LONG)sizeLarge-2); - stringSize.cy = std::min(stringSize.cy, (LONG)sizeLarge-2); - - rectText.top = sizeLarge - stringSize.cy - 1; - rectText.left = sizeLarge - stringSize.cx - 1; - rectText.bottom = sizeLarge - 1; - rectText.right = sizeLarge - 1; - - rectBox.top = sizeLarge - stringSize.cy - 2; - rectBox.left = sizeLarge - stringSize.cx - 2; - rectBox.bottom = sizeLarge; - rectBox.right = sizeLarge; - - //Draw the background (rounded) rectangle - int elipsSize = calSize/3; - RoundRect(dcEditTemp, rectBox.left, rectBox.top, rectBox.right, rectBox.bottom, elipsSize, elipsSize); - //Draw text in the rectangle - DrawText(dcEditTemp, m_szFilePath, m_nameLength, &rectText, DT_BOTTOM|DT_SINGLELINE|DT_LEFT); - - //set alpha of non white pixels back to 255 - //premultiply alpha - //Fill in the mask bitmap (anything not 100% alpha is transparent) - int red, green, blue, alpha; - for(int y = 0; y < sizeLarge; y++) { - for(int x = 0; x < sizeLarge; x++) { - DWORD * pix = pPix+(y*sizeLarge+x); - red = *pix & 0xFF; - green = *pix >> 8 & 0xFF; - blue = *pix >> 16 & 0xFF; - alpha = *pix >> 24 & 0xFF; - if ((*pix << 8) == 0xFFFFFF00) - alpha = 0x00; - else - alpha = 0xFF; - red = (red*alpha)/0xFF; - green = (green*alpha)/0xFF; - blue = (blue*alpha)/0xFF; - *pix = RGBA(red, green, blue, alpha); - } - } - - BLENDFUNCTION ftn = { AC_SRC_OVER, 0, 0xFF, AC_SRC_ALPHA }; - int width = rectBox.right - rectBox.left; - int height = rectBox.bottom - rectBox.top; - AlphaBlend(dcEditColor, rectBox.left, rectBox.top, stringSize.cx, stringSize.cy, dcEditTemp, rectBox.left, rectBox.top, width, height, ftn); - - //Adjust the mask image: simply draw the rectangle to it - backGround = RGB(0, 0, 0); - DeleteBrush(brush); - DeletePen(pen); - brush = CreateSolidBrush(backGround); - pen = CreatePen(PS_NULL, 0, backGround); - SelectObject(dcEditMask, brush); - SelectObject(dcEditMask, pen); - RoundRect(dcEditMask, rectBox.left, rectBox.top, rectBox.right, rectBox.bottom, elipsSize, elipsSize); - - - DeleteDC(dcEditColor); - DeleteDC(dcEditMask); - DeleteDC(dcEditTemp); - DeleteBrush(brush); - DeletePen(pen); - DeleteFont(font); - DeleteBitmap(hbm); - - *phiconLarge = CreateIconIndirect(&iconinfo); - DeleteBitmap(iconinfo.hbmColor); - DeleteBitmap(iconinfo.hbmMask); - - if (*phiconLarge == NULL) { - InvalidateIcon(phiconSmall, phiconLarge); - return S_FALSE; - } - - return S_OK; -} - -void InvalidateIcon(HICON * iconSmall, HICON * iconLarge) { - if (iconSmall && *iconSmall) { - DestroyIcon(*iconSmall); - *iconSmall = NULL; - } - if (iconLarge && *iconLarge) { - DestroyIcon(*iconLarge); - *iconLarge = NULL; - } -} - -// *** Private methods *** -STDMETHODIMP CShellExt::InvokeNPP(HWND /*hParent*/, LPCSTR /*pszWorkingDir*/, LPCSTR /*pszCmd*/, LPCSTR /*pszParam*/, int iShowCmd) { - TCHAR szFilename[MAX_PATH]; - TCHAR szCustom[MAX_PATH]; - TCHAR szNotepadExecutableFilename[3 * MAX_PATH]; // Should be able to contain szFilename plus szCustom plus some additional characters. - LPTSTR pszCommand; - size_t bytesRequired = 1; - - memset(szNotepadExecutableFilename, 0, sizeof(TCHAR) * 3 * MAX_PATH); - - TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE]; - DWORD regSize = 0; - DWORD pathSize = MAX_PATH; - HKEY settingKey; - LONG result; - - wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID); - result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey); - if (result != ERROR_SUCCESS) { - MsgBoxError(TEXT("Unable to open registry key.")); - return E_FAIL; - } - - result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, NULL, ®Size); - if (result == ERROR_SUCCESS) { - bytesRequired += regSize+2; - } else { - MsgBoxError(TEXT("Cannot read path to executable.")); - RegCloseKey(settingKey); - return E_FAIL; - } - - result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, NULL, ®Size); - if (result == ERROR_SUCCESS) { - bytesRequired += regSize; - } - - for (UINT i = 0; i < m_cbFiles; i++) { - bytesRequired += DragQueryFile((HDROP)m_stgMedium.hGlobal, i, NULL, 0); - bytesRequired += 3; - } - - bytesRequired *= sizeof(TCHAR); - pszCommand = (LPTSTR)CoTaskMemAlloc(bytesRequired); - if (!pszCommand) { - MsgBoxError(TEXT("Insufficient memory available.")); - RegCloseKey(settingKey); - return E_FAIL; - } - *pszCommand = 0; - - regSize = (DWORD)MAX_PATH*sizeof(TCHAR); - result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, (LPBYTE)(szFilename), ®Size); - szFilename[MAX_PATH-1] = 0; - lstrcat(szNotepadExecutableFilename, TEXT("\"")); - lstrcat(szNotepadExecutableFilename, szFilename); - lstrcat(szNotepadExecutableFilename, TEXT("\"")); - result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(szCustom), &pathSize); - if (result == ERROR_SUCCESS) { - lstrcat(szNotepadExecutableFilename, TEXT(" ")); - lstrcat(szNotepadExecutableFilename, szCustom); - } - RegCloseKey(settingKey); - - // We have to open the files in batches. A command on the command-line can be at most - // 2048 characters in XP and 32768 characters in Win7. In the degenerate case where all - // paths are of length MAX_PATH, we can open at most x files at once, where: - // 260 * (x + 2) = 2048 or 32768 <=> x = 5 or x = 124. - // Note the +2 to account for the path to notepad++.exe. - // http://stackoverflow.com/questions/3205027/maximum-length-of-command-line-string - - const UINT kiBatchSize = m_winVer > WINVER_XP ? 100 : 4; - - UINT iFileIndex = 0; - while(iFileIndex < m_cbFiles) { - memset(pszCommand, 0, bytesRequired); - lstrcat(pszCommand, szNotepadExecutableFilename); - for (UINT iBatchSizeCounter = 0; iFileIndex < m_cbFiles && iBatchSizeCounter < kiBatchSize; iBatchSizeCounter++) { - DragQueryFile((HDROP)m_stgMedium.hGlobal, iFileIndex, szFilename, MAX_PATH); - lstrcat(pszCommand, TEXT(" \"")); - lstrcat(pszCommand, szFilename); - lstrcat(pszCommand, TEXT("\"")); - iFileIndex++; - } - - STARTUPINFO si; - PROCESS_INFORMATION pi; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESHOWWINDOW; - si.wShowWindow = (WORD)iShowCmd; //SW_RESTORE; - if (!CreateProcess (NULL, pszCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { - DWORD errorCode = GetLastError(); - if (errorCode == ERROR_ELEVATION_REQUIRED) { //Fallback to shellexecute - CoInitializeEx(NULL, 0); - HINSTANCE execVal = ShellExecute(NULL, TEXT("runas"), pszCommand, NULL, NULL, iShowCmd); - CoUninitialize(); - if (execVal <= (HINSTANCE)32) { - TCHAR * message = new TCHAR[512+bytesRequired]; - wsprintf(message, TEXT("ShellExecute failed (%d): Is this command correct?\r\n%s"), execVal, pszCommand); - MsgBoxError(message); - delete [] message; - } - } else { - TCHAR * message = new TCHAR[512+bytesRequired]; - wsprintf(message, TEXT("Error in CreateProcess (%d): Is this command correct?\r\n%s"), errorCode, pszCommand); - MsgBoxError(message); - delete [] message; - } - } - } - - - - CoTaskMemFree(pszCommand); - return NOERROR; -} - -STDMETHODIMP CShellExt::LoadShellIcon(int cx, int cy, HICON * phicon) { - HRESULT hr = E_OUTOFMEMORY; - HICON hicon = NULL; - - if (m_useCustom) { - hicon = (HICON)LoadImage(NULL, m_szCustomPath, IMAGE_ICON, cx, cy, LR_DEFAULTCOLOR|LR_LOADFROMFILE); - } - - //Either no custom defined, or failed and use fallback - if (hicon == NULL) { - hicon = (HICON)LoadImage(_hModule, MAKEINTRESOURCE(IDI_ICON_NPP), IMAGE_ICON, cx, cy, LR_DEFAULTCOLOR); - } - - if (hicon == NULL) { - hr = E_OUTOFMEMORY; - *phicon = NULL; - } else { - hr = S_OK; - *phicon = hicon; - } - - return hr; -} diff --git a/PowerEditor/src/tools/NppShell/src/NppShell.h b/PowerEditor/src/tools/NppShell/src/NppShell.h deleted file mode 100755 index 6e806f218..000000000 --- a/PowerEditor/src/tools/NppShell/src/NppShell.h +++ /dev/null @@ -1,132 +0,0 @@ -//--------------------------------------------------------------------------- -// Copyright 2002-2003 by Andre Burgaud -// Copyright 2009 by Harry -// See license.txt -//--------------------------------------------------------------------------- - -#ifndef STRICT -#define STRICT -#endif - -#define INC_OLE2 -#define NOMINMAX - -#include -#include -#include -#include - -#define WINVER_VISTA 0x600 -#define WINVER_XP 0x0501 - -//This is not ideal, but missing from current mingw -#ifndef ERROR_ELEVATION_REQUIRED -#define ERROR_ELEVATION_REQUIRED 740 -#endif - -#define GIL_DEFAULTICON 0x0040 - -#define GUID_SIZE 128 -#define GUID_STRING_SIZE 40 -#define TITLE_SIZE 64 - -#ifdef ARRAYSIZE -#undef ARRAYSIZE -#endif -#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) - -#define MAX_CMD_LENGTH 32767 -#define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i))) - -#define INITGUID -#include -#include - -#ifdef WIN64 -// {B298D29A-A6ED-11DE-BA8C-A68E55D89593} -DEFINE_GUID(CLSID_ShellExtension, 0xB298D29A, 0xA6ED, 0x11DE, 0xBA, 0x8C, 0xA6, 0x8E, 0x55, 0xD8, 0x95, 0x93); -TCHAR szGUID[] = TEXT("{B298D29A-A6ED-11DE-BA8C-A68E55D89593}"); -#else -// {00F3C2EC-A6EE-11DE-A03A-EF8F55D89593} -DEFINE_GUID(CLSID_ShellExtension, 0x00F3C2EC, 0xA6EE, 0x11DE, 0xA0, 0x3A, 0xEF, 0x8F, 0x55, 0xD8, 0x95, 0x93); -TCHAR szGUID[] = TEXT("{00F3C2EC-A6EE-11DE-A03A-EF8F55D89593}"); -#endif - -class CShellExtClassFactory : public IClassFactory { -protected: - ULONG m_cRef; - -public: - CShellExtClassFactory(); - virtual ~CShellExtClassFactory(); - - // *** IUnknown methods *** - STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - // *** IClassFactory methods *** - STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *); - STDMETHODIMP LockServer(BOOL); -}; - -class CShellExt : public IContextMenu3, IShellExtInit, IPersistFile, IExtractIcon { -private: - // - ULONG m_cRef; - - // Menu variables - UINT m_cbFiles; - STGMEDIUM m_stgMedium; - LPDATAOBJECT m_pDataObj; - TCHAR m_szDllDir[MAX_PATH]; - TCHAR m_szMenuTitle[TITLE_SIZE]; - UINT m_menuID; - HMENU m_hMenu; - bool m_showIcon; - // Icon variables - TCHAR m_szFilePath[MAX_PATH]; - TCHAR m_szModule[MAX_PATH]; - TCHAR m_szCustomPath[MAX_PATH]; - bool m_useCustom; - int m_nameLength; - int m_nameMaxLength; - bool m_isDynamic; - HBITMAP m_hBitmap; - - DWORD m_winVer; //current windows version - - // *** Private methods *** - STDMETHODIMP InvokeNPP(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd); - STDMETHODIMP LoadShellIcon(int cx, int cy, HICON * phicon); - -public: - CShellExt(); - virtual ~CShellExt(); - - // *** IUnknown methods *** - STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - - // *** IShellExtInit methods *** - STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID); - - // *** IContextMenu methods *** - STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); - STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi); - STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax); - STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) { return HandleMenuMsg2(uMsg, wParam, lParam, NULL); }; - STDMETHODIMP HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult); - - // *** IPersistFile methods *** - STDMETHODIMP GetClassID(CLSID *) { return E_NOTIMPL; }; - STDMETHODIMP IsDirty(void) { return E_NOTIMPL; }; - STDMETHODIMP Save(LPCOLESTR, BOOL) { return E_NOTIMPL; }; - STDMETHODIMP SaveCompleted(LPCOLESTR) { return E_NOTIMPL; }; - STDMETHODIMP GetCurFile(LPOLESTR *) { return E_NOTIMPL; }; - STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode); - - // *** IExtractIcon methods *** - STDMETHODIMP GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax, int * piIndex, UINT * pwFlags); - STDMETHODIMP Extract(LPCTSTR pszFile, UINT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIconSize); -}; diff --git a/PowerEditor/src/tools/NppShell/src/NppShell.rc b/PowerEditor/src/tools/NppShell/src/NppShell.rc deleted file mode 100644 index e91bfe014..000000000 --- a/PowerEditor/src/tools/NppShell/src/NppShell.rc +++ /dev/null @@ -1,77 +0,0 @@ -#include "resource.h" -#include "winresrc.h" -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,1,0,0 - PRODUCTVERSION 0,1,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x3L -#else - FILEFLAGS 0x2L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN -#ifdef WIN64 - VALUE "FileDescription", "ShellHandler for Notepad++ (64 bit)" -#else - VALUE "FileDescription", "ShellHandler for Notepad++" -#endif - VALUE "FileVersion", "0.1" - VALUE "LegalCopyright", "Copyright © 2010" -#ifdef WIN64 - VALUE "OriginalFilename", "NppShell64.dll" -#else - VALUE "OriginalFilename", "NppShell.dll" -#endif - VALUE "ProductVersion", "0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -//IDI_ICON_NPP ICON "icon\\npp_1.ico" -IDI_ICON_NPP ICON "icon\\nppNewIcon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_DIALOG_SETTINGS DIALOGEX 0, 0, 286, 149 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "NppShell Settings" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Context Menu",IDC_STATIC,6,6,132,114 - CONTROL "Add context menu item",IDC_CHECK_USECONTEXT,"Button",BS_AUTO3STATE | WS_TABSTOP,18,24,90,10 - CONTROL "Show icon",IDC_CHECK_CONTEXTICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,42,48,10 - LTEXT "Menu text",IDC_STATIC,18,54,34,8 - EDITTEXT IDC_EDIT_MENU,24,66,102,14,ES_AUTOHSCROLL - LTEXT "Command line params",IDC_STATIC,18,84,70,8 - EDITTEXT IDC_EDIT_COMMAND,24,96,102,14,ES_AUTOHSCROLL - GROUPBOX "Dynamic Icon",IDC_STATIC,144,6,132,114 - CONTROL "Show dynamic icon",IDC_CHECK_USEICON,"Button",BS_AUTO3STATE | WS_TABSTOP,156,24,76,10 - CONTROL "Show extension",IDC_CHECK_ISDYNAMIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,42,67,10 - DEFPUSHBUTTON "OK",IDOK,222,126,50,14 -END diff --git a/PowerEditor/src/tools/NppShell/src/bitmap/npp.bmp b/PowerEditor/src/tools/NppShell/src/bitmap/npp.bmp deleted file mode 100644 index d0cf724e9..000000000 Binary files a/PowerEditor/src/tools/NppShell/src/bitmap/npp.bmp and /dev/null differ diff --git a/PowerEditor/src/tools/NppShell/src/export.def b/PowerEditor/src/tools/NppShell/src/export.def deleted file mode 100644 index 400e3316b..000000000 --- a/PowerEditor/src/tools/NppShell/src/export.def +++ /dev/null @@ -1,6 +0,0 @@ -EXPORTS -DllRegisterServer PRIVATE -DllUnregisterServer PRIVATE -DllInstall PRIVATE -DllGetClassObject PRIVATE -DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/PowerEditor/src/tools/NppShell/src/icon/nppNewIcon.ico b/PowerEditor/src/tools/NppShell/src/icon/nppNewIcon.ico deleted file mode 100644 index 2bf7aaa57..000000000 Binary files a/PowerEditor/src/tools/NppShell/src/icon/nppNewIcon.ico and /dev/null differ diff --git a/PowerEditor/src/tools/NppShell/src/icon/npp_0.ico b/PowerEditor/src/tools/NppShell/src/icon/npp_0.ico deleted file mode 100644 index 1ae54139c..000000000 Binary files a/PowerEditor/src/tools/NppShell/src/icon/npp_0.ico and /dev/null differ diff --git a/PowerEditor/src/tools/NppShell/src/icon/npp_1.ico b/PowerEditor/src/tools/NppShell/src/icon/npp_1.ico deleted file mode 100644 index bb90d41f7..000000000 Binary files a/PowerEditor/src/tools/NppShell/src/icon/npp_1.ico and /dev/null differ diff --git a/PowerEditor/src/tools/NppShell/src/resource.h b/PowerEditor/src/tools/NppShell/src/resource.h deleted file mode 100644 index 9cbf009cf..000000000 --- a/PowerEditor/src/tools/NppShell/src/resource.h +++ /dev/null @@ -1,12 +0,0 @@ -#define IDI_ICON_NPP 102 - -#define IDD_DIALOG_SETTINGS 101 - -#define IDC_CHECK_USECONTEXT 1000 -#define IDC_CHECK_CONTEXTICON 1001 -#define IDC_EDIT_MENU 1002 -#define IDC_EDIT_COMMAND 1003 -#define IDC_CHECK_USEICON 1004 -#define IDC_CHECK_ISDYNAMIC 1005 - -#define IDC_STATIC -1