From 6e0caa10c688bcda8c61ff40de76703b6709ca3a Mon Sep 17 00:00:00 2001 From: donho Date: Mon, 29 Dec 2008 01:32:52 +0000 Subject: [PATCH] [ADD] Add a new Unicode compliant nppCM project. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@377 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/tools/nppCM/Makefile | 24 ++ PowerEditor/src/tools/nppCM/license.txt | 19 + PowerEditor/src/tools/nppCM/npp.bmp | Bin 0 -> 1334 bytes PowerEditor/src/tools/nppCM/nppcm.RES | Bin 0 -> 2248 bytes PowerEditor/src/tools/nppCM/nppcm.cpp | 481 ++++++++++++++++++++++++ PowerEditor/src/tools/nppCM/nppcm.def | 10 + PowerEditor/src/tools/nppCM/nppcm.h | 79 ++++ PowerEditor/src/tools/nppCM/nppcm.rc | 116 ++++++ PowerEditor/src/tools/nppCM/readme.txt | 62 +++ PowerEditor/src/tools/nppCM/resource.h | 17 + 10 files changed, 808 insertions(+) create mode 100644 PowerEditor/src/tools/nppCM/Makefile create mode 100644 PowerEditor/src/tools/nppCM/license.txt create mode 100644 PowerEditor/src/tools/nppCM/npp.bmp create mode 100644 PowerEditor/src/tools/nppCM/nppcm.RES create mode 100644 PowerEditor/src/tools/nppCM/nppcm.cpp create mode 100644 PowerEditor/src/tools/nppCM/nppcm.def create mode 100644 PowerEditor/src/tools/nppCM/nppcm.h create mode 100644 PowerEditor/src/tools/nppCM/nppcm.rc create mode 100644 PowerEditor/src/tools/nppCM/readme.txt create mode 100644 PowerEditor/src/tools/nppCM/resource.h diff --git a/PowerEditor/src/tools/nppCM/Makefile b/PowerEditor/src/tools/nppCM/Makefile new file mode 100644 index 00000000..2058468f --- /dev/null +++ b/PowerEditor/src/tools/nppCM/Makefile @@ -0,0 +1,24 @@ +TARGETOS = BOTH +!include + +lflags = /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO +dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll + +all: nppcm.dll + +nppcm.dll: nppcm.obj nppcm.res + $(implib) -machine:$(CPU) -def:nppcm.def $** -out:nppcm.lib + $(link) $(dlllflags) -base:0x1C000000 -out:$*.dll $** $(olelibsdll) shell32.lib nppcm.lib comctl32.lib nppcm.exp + +.cpp.obj: + $(cc) $(cflags) $(cvarsdll) $*.cpp + +nppcm.res: nppcm.rc + $(rc) $(rcflags) $(rcvars) nppcm.rc + +clean: + -1 del nppcm.dll nppcm.obj nppcm.exp nppcm.res + +zip: + -1 del *.zip + perl abpack.pl \ No newline at end of file diff --git a/PowerEditor/src/tools/nppCM/license.txt b/PowerEditor/src/tools/nppCM/license.txt new file mode 100644 index 00000000..16618f39 --- /dev/null +++ b/PowerEditor/src/tools/nppCM/license.txt @@ -0,0 +1,19 @@ +Copyright (c) 2003 Andre Burgaud (http://www.burgaud.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/PowerEditor/src/tools/nppCM/npp.bmp b/PowerEditor/src/tools/nppCM/npp.bmp new file mode 100644 index 0000000000000000000000000000000000000000..92ae60e6ccd3ab8426ae7cc6e5180b56fa180405 GIT binary patch literal 1334 zcmeIxyKmD_6bA4wG%ZmHQH6N5AR5HWp*&O-+Q`7-N<324;w7~zEzy-3q6R3{9kY7O z=+Uc3j~>0=(c>NO>d~V|^Eu@oV6UZL&OP@#j_t^Cb~ooSJ2snu#nsY34YbaJ##xzt z)@yPG2N;jXkWxZUBz)h898WQwPB94r1hp`L5NNOs96Qvl$DUu{bN^#0c(@^nx6f1a%!k99e zqzZ~6#Y!0&O0s&LL1h^-Qks=?qR~^Dxn`!BY3Q0JqhTl~ooh@IgI;P7C<7-mm{6t- zXIYKmtl_M|lFD(HLK~ z6lKZz5>;I*Rw{}Ls;oF$F{_wW$f}Cxv8U?X`ET%_@4!N{(YVlTclrOH9Vkf}ke*YXCeR*E@*2C2;>&311oqIp-zmzR^)v~(XYgb17 jwfBE6ZMOE@{cXEzUA1|`w;#`U_+5Rgd$}`v+TQiQH`M7Y literal 0 HcmV?d00001 diff --git a/PowerEditor/src/tools/nppCM/nppcm.RES b/PowerEditor/src/tools/nppCM/nppcm.RES new file mode 100644 index 0000000000000000000000000000000000000000..ab2ad2f926e5cbb35f147f8b0a228f497157e5ba GIT binary patch literal 2248 zcmeHHJ#gD(7=9eP!3`#tr{SAeTH2{7deX}gHR)eG2Bq+&n+j&RWoewqu-+!)2dp@(v%uaK$;%U|WFC^^ zfL$oo8s4aZD~$iZnB1w6^w;E_rSomnSoyf;QC}W^G4tn~r0i=a+9G}5u|kEXtJFtl zB|S?o!&(o?lRH&8T}8c~yaC`kCdj*Y(u2HN>Fjj2V#ynmnK!x1wC0$l!Htvq-cQc{ zN~YXe`jGFUG7{gTeZ`! zx?YH)AEHJ0K}arT7?K;38)C}q<3plHtoeN`gnh>Pj1m1lB4R-FBgz4}L4*Y&=tl^n zi2ewX$N^;>VJjT)+yK#FK>h%+$e5Cdq8Q#FCO2j*W-Nx!Kj4TM5b-O#n!*442F5d~ z)L15$=kGsRmz1fLpH^rC@T zL+z`YGRK8q-n)D4;?K2`QYy=Mp`b5beE4p?to929#%ZrCTz_(5dA*c1X={e2-+l1? z(}_>S&Z$XFU!ME=_K){pTmOi0r5n1gFMe}%^~nT_=9FO=rRRIQjkTv6pNXw~JiV+f zy_fsoa^=bwX4aV2w0!>UH*1C2JI&X>%sw(6ujqO0Eu9U&|LM6&<|=6UHzt$Y&b;$4 Dun%we literal 0 HcmV?d00001 diff --git a/PowerEditor/src/tools/nppCM/nppcm.cpp b/PowerEditor/src/tools/nppCM/nppcm.cpp new file mode 100644 index 00000000..b671543f --- /dev/null +++ b/PowerEditor/src/tools/nppCM/nppcm.cpp @@ -0,0 +1,481 @@ +//--------------------------------------------------------------------------- +// Copyright 2002-2003 by Andre Burgaud +// See license.txt +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// wscitecm.cpp +// Defines the entry point for the DLL application. +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// Modified by Don HO +// to meet the need of Notepad++ +//--------------------------------------------------------------------------- + + +#ifndef STRICT +#define STRICT +#endif + +#define INC_OLE2 +#define UNICODE + +#ifdef UNICODE + #define generic_strrchr wcsrchr +#else + + #define generic_strrchr strrchr + +#endif + + +#include +#include +#include + +#define GUID_SIZE 128 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) +#define MAX_FILES 10 +#define MAX_CMDSTR (MAX_PATH * MAX_FILES) +#define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i))) + +#pragma data_seg(".text") +#define INITGUID +#include +#include +#include "resource.h" +#include "nppcm.h" +#pragma data_seg() + +//--------------------------------------------------------------------------- +// Global variables +//--------------------------------------------------------------------------- +UINT _cRef = 0; // COM Reference count. +HINSTANCE _hModule = NULL; // DLL Module. + +typedef struct{ + HKEY hRootKey; + LPTSTR szSubKey; + LPTSTR lpszValueName; + LPTSTR szData; +} DOREGSTRUCT, *LPDOREGSTRUCT; + +TCHAR szNppName[] = TEXT("notepad++.exe"); +TCHAR szShellExtensionTitle[] = TEXT("Notepad++"); + +BOOL RegisterServer(CLSID, LPTSTR); +BOOL UnregisterServer(CLSID, LPTSTR); +void MsgBox(LPTSTR); +void MsgBoxDebug(LPTSTR); +void MsgBoxError(LPTSTR); + +//--------------------------------------------------------------------------- +// DllMain +//--------------------------------------------------------------------------- +extern "C" int APIENTRY +DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { + if (dwReason == DLL_PROCESS_ATTACH) { + _hModule = hInstance; + } + return 1; +} + +//--------------------------------------------------------------------------- +// 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() { + return (RegisterServer(CLSID_ShellExtension, szShellExtensionTitle) ? S_OK : E_FAIL); +} + +//--------------------------------------------------------------------------- +// DllUnregisterServer +//--------------------------------------------------------------------------- +STDAPI DllUnregisterServer(void) { + return (UnregisterServer(CLSID_ShellExtension, szShellExtensionTitle) ? S_OK : E_FAIL); +} + +//--------------------------------------------------------------------------- +// CheckNpp +//--------------------------------------------------------------------------- +BOOL CheckNpp() { + TCHAR szModuleFullName[MAX_PATH]; + TCHAR szExeFullName[MAX_PATH]; + int nLenPath = 0; + TCHAR* pDest; + LPTSTR *lpFilePart = NULL; + + GetModuleFileName(_hModule, szModuleFullName, MAX_PATH); + pDest = generic_strrchr(szModuleFullName, '\\' ); + pDest++; + pDest[0] = 0; + + DWORD dw = SearchPath(szModuleFullName, szShellExtensionTitle, TEXT(".exe"), MAX_PATH, szExeFullName, lpFilePart); + + return (dw ? TRUE : FALSE); +} + +//--------------------------------------------------------------------------- +// RegisterServer +//--------------------------------------------------------------------------- +BOOL RegisterServer(CLSID clsid, LPTSTR lpszTitle) { + int i; + HKEY hKey; + LRESULT lResult; + DWORD dwDisp; + TCHAR szSubKey[MAX_PATH]; + TCHAR szCLSID[MAX_PATH]; + TCHAR szModule[MAX_PATH]; + LPWSTR pwsz; + + if (!CheckNpp()) { + MsgBoxError(TEXT("To register the Notepad++ context menu extension,\r\ninstall nppcm.dll in the same directory than Notepad++.exe.")); + return FALSE; + } + + StringFromIID(clsid, &pwsz); + if(pwsz) { +#ifdef UNICODE + lstrcpy(szCLSID, pwsz); +#else + WideCharToMultiByte(CP_ACP, 0, pwsz, -1, szCLSID, ARRAYSIZE(szCLSID), NULL, NULL); +#endif + //free the string + LPMALLOC pMalloc; + CoGetMalloc(1, &pMalloc); + pMalloc->Free(pwsz); + pMalloc->Release(); + } + + //get this app's path and file name + GetModuleFileName(_hModule, szModule, MAX_PATH); + + DOREGSTRUCT ClsidEntries[] = { + HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, lpszTitle, + HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, szModule, + HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), TEXT("ThreadingModel"), TEXT("Apartment"), + HKEY_CLASSES_ROOT, TEXT("*\\shellex\\ContextMenuHandlers\\Notepad++"), NULL, szCLSID, + NULL, NULL, NULL, NULL + }; + + // Register the CLSID entries + for(i = 0; ClsidEntries[i].hRootKey; i++) { + // Create the sub key string - for this case, insert the file extension + wsprintf(szSubKey, ClsidEntries[i].szSubKey, szCLSID); + 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 + wsprintf(szData, ClsidEntries[i].szData, szModule); + lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, REG_SZ, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR)); + RegCloseKey(hKey); + } + else + return FALSE; + } + return TRUE; +} + +//--------------------------------------------------------------------------- +// UnregisterServer +//--------------------------------------------------------------------------- +BOOL UnregisterServer(CLSID clsid, LPTSTR lpszTitle) { + TCHAR szCLSID[GUID_SIZE + 1]; + TCHAR szCLSIDKey[GUID_SIZE + 32]; + TCHAR szKeyTemp[MAX_PATH + GUID_SIZE]; + LPWSTR pwsz; + + StringFromIID(clsid, &pwsz); + if(pwsz) { +#ifdef UNICODE + lstrcpy(szCLSID, pwsz); +#else + WideCharToMultiByte(CP_ACP, 0, pwsz, -1, szCLSID, ARRAYSIZE(szCLSID), NULL, NULL); +#endif + //free the string + LPMALLOC pMalloc; + CoGetMalloc(1, &pMalloc); + pMalloc->Free(pwsz); + pMalloc->Release(); + } + + lstrcpy(szCLSIDKey, TEXT("CLSID\\")); + lstrcat(szCLSIDKey, szCLSID); + + wsprintf(szKeyTemp, TEXT("*\\shellex\\ContextMenuHandlers\\%s"), lpszTitle); + RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp); + + wsprintf(szKeyTemp, TEXT("%s\\%s"), szCLSIDKey, TEXT("InprocServer32")); + RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp); + RegDeleteKey(HKEY_CLASSES_ROOT, szCLSIDKey); + + return TRUE; +} + +//--------------------------------------------------------------------------- +// MsgBoxDebug +//--------------------------------------------------------------------------- +void MsgBoxDebug(LPTSTR lpszMsg) { + MessageBox(NULL, + lpszMsg, + TEXT("DEBUG"), + MB_OK); +} + +//--------------------------------------------------------------------------- +// MsgBox +//--------------------------------------------------------------------------- +void MsgBox(LPTSTR lpszMsg) { + MessageBox(NULL, + lpszMsg, + TEXT("Notepad++ Extension"), + MB_OK); +} + +//--------------------------------------------------------------------------- +// MsgBoxError +//--------------------------------------------------------------------------- +void MsgBoxError(LPTSTR lpszMsg) { + MessageBox(NULL, + lpszMsg, + TEXT("Notepad++ Extension"), + MB_OK | MB_ICONSTOP); +} + +//--------------------------------------------------------------------------- +// CShellExtClassFactory +//--------------------------------------------------------------------------- +CShellExtClassFactory::CShellExtClassFactory() { + m_cRef = 0L; + _cRef++; +} + +CShellExtClassFactory::~CShellExtClassFactory() { + _cRef--; +} + +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; +} + +STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) { + *ppvObj = NULL; + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + LPCSHELLEXT pShellExt = new CShellExt(); + if (NULL == pShellExt) + return E_OUTOFMEMORY; + return pShellExt->QueryInterface(riid, ppvObj); +} + +STDMETHODIMP CShellExtClassFactory::LockServer(BOOL fLock) { + return NOERROR; +} + +//--------------------------------------------------------------------------- +// CShellExt +//--------------------------------------------------------------------------- +CShellExt::CShellExt() { + m_cRef = 0L; + m_pDataObj = NULL; + _cRef++; + m_hNppBmp = LoadBitmap(_hModule, MAKEINTRESOURCE(IDB_NPP)); + HRESULT hr; + hr = SHGetMalloc(&m_pAlloc); + if (FAILED(hr)) + m_pAlloc = NULL; +} + +CShellExt::~CShellExt() { + if (m_pDataObj) + m_pDataObj->Release(); + _cRef--; + m_pAlloc->Release(); +} + +STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv) { + *ppv = NULL; + if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown)) { + *ppv = (LPSHELLEXTINIT)this; + } + else if (IsEqualIID(riid, IID_IContextMenu)) { + *ppv = (LPCONTEXTMENU)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; +} + +STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey) { + HRESULT hres = 0; + if (m_pDataObj) + m_pDataObj->Release(); + if (pDataObj) { + m_pDataObj = pDataObj; + pDataObj->AddRef(); + } + return NOERROR; +} + +STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { + UINT idCmd = idCmdFirst; + BOOL bAppendItems=TRUE; + TCHAR szItemNpp[] = TEXT("Edit with &Notepad++"); + + 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++, szItemNpp); + + if (m_hNppBmp) { + SetMenuItemBitmaps (hMenu, nIndex, MF_BYPOSITION, m_hNppBmp, m_hNppBmp); + } + + 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; + } + } + return hr; +} + +STDMETHODIMP CShellExt::GetCommandString(UINT idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax) { + if (uFlags == GCS_HELPTEXT && cchMax > 35) + strcpy(pszName, "Edits the selected file(s) with Notepad++"); + return NOERROR; +} + +static void getNppName(TCHAR *name) { + TCHAR szModuleFullName[MAX_PATH]; + int nLenPath = 0; + TCHAR* pDest; + + name[0] = 0; + GetModuleFileName(_hModule, szModuleFullName, MAX_PATH); + pDest = generic_strrchr(szModuleFullName, '\\' ); + pDest++; + pDest[0] = 0; + lstrcpy(name, szModuleFullName); + lstrcat(name, szNppName); + + if (name[0] == 0) + lstrcpy(name, szNppName); +} + +STDMETHODIMP CShellExt::InvokeNpp(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd) { + TCHAR szFileUserClickedOn[MAX_PATH]; + LPTSTR pszCommand; + UINT i; + + FORMATETC fmte = { + CF_HDROP, + (DVTARGETDEVICE FAR *)NULL, + DVASPECT_CONTENT, + -1, + TYMED_HGLOBAL + }; + + pszCommand = (LPTSTR)m_pAlloc->Alloc(MAX_PATH * (m_cbFiles + 1) * sizeof(TCHAR)); + + if (pszCommand) + getNppName(pszCommand); + else { + MsgBoxError(TEXT("Insufficient memory available.")); + return E_FAIL; + } + + for (i = 0; i < m_cbFiles; i++) { + DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFileUserClickedOn, MAX_PATH); + lstrcat(pszCommand, TEXT(" \"")); + lstrcat(pszCommand, szFileUserClickedOn); + lstrcat(pszCommand, TEXT("\"")); + } + + STARTUPINFO si; + PROCESS_INFORMATION pi; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESHOWWINDOW; + si.wShowWindow = SW_RESTORE; + if (!CreateProcess (NULL, pszCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { + MessageBox(hParent, + TEXT("Error creating process: nppcm.dll needs to be in the same directory than notepad++.exe"), + TEXT("Notepad++ Extension"), + MB_OK); + } + + m_pAlloc->Free(pszCommand); + return NOERROR; +} diff --git a/PowerEditor/src/tools/nppCM/nppcm.def b/PowerEditor/src/tools/nppCM/nppcm.def new file mode 100644 index 00000000..f60eedd3 --- /dev/null +++ b/PowerEditor/src/tools/nppCM/nppcm.def @@ -0,0 +1,10 @@ +;nppcm.def : Declares the module parameters for the DLL. + +LIBRARY nppcm +DESCRIPTION 'Notepad++ Shell Extension' + +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE diff --git a/PowerEditor/src/tools/nppCM/nppcm.h b/PowerEditor/src/tools/nppCM/nppcm.h new file mode 100644 index 00000000..f3b0ed34 --- /dev/null +++ b/PowerEditor/src/tools/nppCM/nppcm.h @@ -0,0 +1,79 @@ +//--------------------------------------------------------------------------- +// Copyright 2002-2003 by Andre Burgaud +// See license.txt +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// wscitecm.h +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// Modified by Don HO +// to meet the need of Notepad++ +//--------------------------------------------------------------------------- + +// {120b94b5-2e6a-4f13-94d0-414bcb64fa0f} +DEFINE_GUID(CLSID_ShellExtension, 0x120b94b5, 0x2e6a, 0x4f13, 0x94, 0xd0, 0x41, 0x4b, 0xcb, 0x64, 0xfa, 0x0f); + + +class CShellExtClassFactory : public IClassFactory { +protected: + ULONG m_cRef; + +public: + CShellExtClassFactory(); + ~CShellExtClassFactory(); + + STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *); + STDMETHODIMP LockServer(BOOL); +}; +typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY; + +class CShellExt : public IContextMenu, IShellExtInit { +public: +protected: + ULONG m_cRef; + UINT m_cbFiles; + STGMEDIUM m_stgMedium; + LPDATAOBJECT m_pDataObj; + HBITMAP m_hNppBmp; + LPMALLOC m_pAlloc; + TCHAR m_szDllDir [MAX_PATH]; + + STDMETHODIMP InvokeNpp(HWND hParent, + LPCSTR pszWorkingDir, + LPCSTR pszCmd, + LPCSTR pszParam, + int iShowCmd); + +public: + CShellExt(); + ~CShellExt(); + + STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + STDMETHODIMP QueryContextMenu(HMENU hMenu, + UINT indexMenu, + UINT idCmdFirst, + UINT idCmdLast, + UINT uFlags); + + STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi); + + STDMETHODIMP GetCommandString(UINT idCmd, + UINT uFlags, + UINT FAR *reserved, + LPSTR pszName, + UINT cchMax); + + STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder, + LPDATAOBJECT pDataObj, + HKEY hKeyID); +}; + +typedef CShellExt *LPCSHELLEXT; diff --git a/PowerEditor/src/tools/nppCM/nppcm.rc b/PowerEditor/src/tools/nppCM/nppcm.rc new file mode 100644 index 00000000..62d03b71 --- /dev/null +++ b/PowerEditor/src/tools/nppCM/nppcm.rc @@ -0,0 +1,116 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,3,0,0 + PRODUCTVERSION 1,3,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 + VALUE "Comments", "\0" + VALUE "CompanyName", "Burgaud.com\0" + VALUE "FileDescription", "Context Handler Menu for Notepad++\0" + VALUE "FileVersion", "1.3\0" + VALUE "InternalName", "\0" + VALUE "LegalCopyright", "Copyright © 2000-2003 Andre Burgaud\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "nppcm.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "\0" + VALUE "ProductVersion", "1.3\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_NPP BITMAP DISCARDABLE "npp.bmp" +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/PowerEditor/src/tools/nppCM/readme.txt b/PowerEditor/src/tools/nppCM/readme.txt new file mode 100644 index 00000000..a2f3bdcc --- /dev/null +++ b/PowerEditor/src/tools/nppCM/readme.txt @@ -0,0 +1,62 @@ + +Overview +-------- +nppcm.dll is a shell extension component for Notepad++. +This component is modified from the MIT open source project WSciTEcm +(Context Menu Extension for SciTE), made by Andre Burgaud , +to meet the need of Notepad++. +Installing this Context Menu Handler (nppcm.dll) creates a new command +"Edit with Notepad++" in the context menu of Windows Explorer. +You can quickly open one or several selected files in Windows Explorer: +right click on the selection and click on the command "Edit with Notepad++". + +The manual installation is describe in the following sections. + + +Installation +------------ +1) Copy nppcm.dll in Notepad++ directory. +2) In Notepad++ directory installation, type the command "regsvr32 nppcm.dll". +This will register the dll. + +If everything goes well, you should have "Edit with Notepad++" +when you right click on selected file(s) in Windows Explorer. + +Uninstallation +-------------- +In Notepad++ directory installation, type the command "regsvr32 /u nppcm.dll". + + +Unload the dll +-------------- +If you try to delete or override the dll file and you get the error "Access is +denied.", the library is already loaded. +There are several options to workaround this issue: + +Solution 1: +- Close all the Windows Explorer instances open on your desktop and copy +nppcm.dll using the command line (Example : "C:/>cp nppcm.dll "). + +Solution 2: +- Reboot the computer and delete or override nppcm.dll (with the command line) +before starting Windows Explorer and using the context menu (right-click). + +Solution 3: +- Open a command line window +- Type CTRL+ALT+DEL to display the Windows Task Manager, display the Process tab +and "kill" the explorer.exe process. +- If your exlorer did not restart automatically, start it manually from the command line window +(c:/>explorer) +- Delete or override nppcm.dll before using the context menu (Example: "C:/>cp nppcm.dll "). + +Build +----- +nppcm.dll is built with Visual C++ 6.0. A Makefile is provided with the +sources: in the source directory, type "nmake". Ensure that all the +environment variables and paths are set correctly. To do so, use the command +file "VCVARS32.BAT" available in the bin directory of Visual C++ installation. + +License +------- +Copyright 2002-2003 by Andre Burgaud +See license.txt \ No newline at end of file diff --git a/PowerEditor/src/tools/nppCM/resource.h b/PowerEditor/src/tools/nppCM/resource.h new file mode 100644 index 00000000..6754d602 --- /dev/null +++ b/PowerEditor/src/tools/nppCM/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by wscitecm.rc +// +#define IDI_SCITE 101 +#define IDB_NPP 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif