[ADD] Add a new Unicode compliant nppCM project.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@377 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
6e4a80da18
commit
6e0caa10c6
24
PowerEditor/src/tools/nppCM/Makefile
Normal file
24
PowerEditor/src/tools/nppCM/Makefile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
TARGETOS = BOTH
|
||||||
|
!include <win32.mak>
|
||||||
|
|
||||||
|
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
|
19
PowerEditor/src/tools/nppCM/license.txt
Normal file
19
PowerEditor/src/tools/nppCM/license.txt
Normal file
@ -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.
|
BIN
PowerEditor/src/tools/nppCM/npp.bmp
Normal file
BIN
PowerEditor/src/tools/nppCM/npp.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
PowerEditor/src/tools/nppCM/nppcm.RES
Normal file
BIN
PowerEditor/src/tools/nppCM/nppcm.RES
Normal file
Binary file not shown.
481
PowerEditor/src/tools/nppCM/nppcm.cpp
Normal file
481
PowerEditor/src/tools/nppCM/nppcm.cpp
Normal file
@ -0,0 +1,481 @@
|
|||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Copyright 2002-2003 by Andre Burgaud <andre@burgaud.com>
|
||||||
|
// See license.txt
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// wscitecm.cpp
|
||||||
|
// Defines the entry point for the DLL application.
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Modified by Don HO <don.h@free.fr>
|
||||||
|
// 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 <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
|
||||||
|
#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 <initguid.h>
|
||||||
|
#include <shlguid.h>
|
||||||
|
#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;
|
||||||
|
}
|
10
PowerEditor/src/tools/nppCM/nppcm.def
Normal file
10
PowerEditor/src/tools/nppCM/nppcm.def
Normal file
@ -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
|
79
PowerEditor/src/tools/nppCM/nppcm.h
Normal file
79
PowerEditor/src/tools/nppCM/nppcm.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Copyright 2002-2003 by Andre Burgaud <andre@burgaud.com>
|
||||||
|
// See license.txt
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// wscitecm.h
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// Modified by Don HO <don.h@free.fr>
|
||||||
|
// 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;
|
116
PowerEditor/src/tools/nppCM/nppcm.rc
Normal file
116
PowerEditor/src/tools/nppCM/nppcm.rc
Normal file
@ -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
|
||||||
|
|
62
PowerEditor/src/tools/nppCM/readme.txt
Normal file
62
PowerEditor/src/tools/nppCM/readme.txt
Normal file
@ -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 <andre@burgaud.com>,
|
||||||
|
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 <npp_directory>").
|
||||||
|
|
||||||
|
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 <npp_directory>").
|
||||||
|
|
||||||
|
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 <andre@burgaud.com>
|
||||||
|
See license.txt
|
17
PowerEditor/src/tools/nppCM/resource.h
Normal file
17
PowerEditor/src/tools/nppCM/resource.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user