mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
[BUG_FIXED] (Author: Andreas Jonsson) Fix a bug in NppShell when trying to open many files.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1239 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
e975e06410
commit
924dc4d4ef
Binary file not shown.
Binary file not shown.
@ -28,10 +28,10 @@
|
|||||||
; Define the application name
|
; Define the application name
|
||||||
!define APPNAME "Notepad++"
|
!define APPNAME "Notepad++"
|
||||||
|
|
||||||
!define APPVERSION "6.6.2"
|
!define APPVERSION "6.6.3"
|
||||||
!define APPNAMEANDVERSION "${APPNAME} v${APPVERSION}"
|
!define APPNAMEANDVERSION "${APPNAME} v${APPVERSION}"
|
||||||
!define VERSION_MAJOR 6
|
!define VERSION_MAJOR 6
|
||||||
!define VERSION_MINOR 62
|
!define VERSION_MINOR 63
|
||||||
|
|
||||||
!define APPWEBSITE "http://notepad-plus-plus.org/"
|
!define APPWEBSITE "http://notepad-plus-plus.org/"
|
||||||
|
|
||||||
@ -606,6 +606,10 @@ Section -"Notepad++" mainSection
|
|||||||
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_04.dll"'
|
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_04.dll"'
|
||||||
Delete "$INSTDIR\NppShell_04.dll"
|
Delete "$INSTDIR\NppShell_04.dll"
|
||||||
|
|
||||||
|
IfFileExists "$INSTDIR\NppShell_05.dll" 0 +3
|
||||||
|
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_05.dll"'
|
||||||
|
Delete "$INSTDIR\NppShell_05.dll"
|
||||||
|
|
||||||
; detect the right of
|
; detect the right of
|
||||||
UserInfo::GetAccountType
|
UserInfo::GetAccountType
|
||||||
Pop $1
|
Pop $1
|
||||||
@ -635,12 +639,12 @@ Section "Context Menu Entry" explorerContextMenu
|
|||||||
SetOverwrite try
|
SetOverwrite try
|
||||||
SetOutPath "$INSTDIR\"
|
SetOutPath "$INSTDIR\"
|
||||||
${If} ${RunningX64}
|
${If} ${RunningX64}
|
||||||
File /oname=$INSTDIR\NppShell_05.dll "..\bin\NppShell64_05.dll"
|
File /oname=$INSTDIR\NppShell_06.dll "..\bin\NppShell64_06.dll"
|
||||||
${Else}
|
${Else}
|
||||||
File "..\bin\NppShell_05.dll"
|
File "..\bin\NppShell_06.dll"
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
Exec 'regsvr32 /s "$INSTDIR\NppShell_05.dll"'
|
Exec 'regsvr32 /s "$INSTDIR\NppShell_06.dll"'
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
SectionGroup "Auto-completion Files" autoCompletionComponent
|
SectionGroup "Auto-completion Files" autoCompletionComponent
|
||||||
@ -1768,11 +1772,13 @@ Section un.explorerContextMenu
|
|||||||
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_03.dll"'
|
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_03.dll"'
|
||||||
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_04.dll"'
|
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_04.dll"'
|
||||||
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_05.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_01.dll"
|
||||||
Delete "$INSTDIR\NppShell_02.dll"
|
Delete "$INSTDIR\NppShell_02.dll"
|
||||||
Delete "$INSTDIR\NppShell_03.dll"
|
Delete "$INSTDIR\NppShell_03.dll"
|
||||||
Delete "$INSTDIR\NppShell_04.dll"
|
Delete "$INSTDIR\NppShell_04.dll"
|
||||||
Delete "$INSTDIR\NppShell_05.dll"
|
Delete "$INSTDIR\NppShell_05.dll"
|
||||||
|
Delete "$INSTDIR\NppShell_06.dll"
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section un.UnregisterFileExt
|
Section un.UnregisterFileExt
|
||||||
|
@ -955,9 +955,12 @@ void InvalidateIcon(HICON * iconSmall, HICON * iconLarge) {
|
|||||||
STDMETHODIMP CShellExt::InvokeNPP(HWND /*hParent*/, LPCSTR /*pszWorkingDir*/, LPCSTR /*pszCmd*/, LPCSTR /*pszParam*/, int iShowCmd) {
|
STDMETHODIMP CShellExt::InvokeNPP(HWND /*hParent*/, LPCSTR /*pszWorkingDir*/, LPCSTR /*pszCmd*/, LPCSTR /*pszParam*/, int iShowCmd) {
|
||||||
TCHAR szFilename[MAX_PATH];
|
TCHAR szFilename[MAX_PATH];
|
||||||
TCHAR szCustom[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;
|
LPTSTR pszCommand;
|
||||||
size_t bytesRequired = 1;
|
size_t bytesRequired = 1;
|
||||||
|
|
||||||
|
memset(szNotepadExecutableFilename, 0, sizeof(TCHAR) * 3 * MAX_PATH);
|
||||||
|
|
||||||
TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE];
|
TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE];
|
||||||
DWORD regSize = 0;
|
DWORD regSize = 0;
|
||||||
DWORD pathSize = MAX_PATH;
|
DWORD pathSize = MAX_PATH;
|
||||||
@ -1002,46 +1005,61 @@ STDMETHODIMP CShellExt::InvokeNPP(HWND /*hParent*/, LPCSTR /*pszWorkingDir*/, LP
|
|||||||
regSize = (DWORD)MAX_PATH*sizeof(TCHAR);
|
regSize = (DWORD)MAX_PATH*sizeof(TCHAR);
|
||||||
result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, (LPBYTE)(szFilename), ®Size);
|
result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, (LPBYTE)(szFilename), ®Size);
|
||||||
szFilename[MAX_PATH-1] = 0;
|
szFilename[MAX_PATH-1] = 0;
|
||||||
lstrcat(pszCommand, TEXT("\""));
|
lstrcat(szNotepadExecutableFilename, TEXT("\""));
|
||||||
lstrcat(pszCommand, szFilename);
|
lstrcat(szNotepadExecutableFilename, szFilename);
|
||||||
lstrcat(pszCommand, TEXT("\""));
|
lstrcat(szNotepadExecutableFilename, TEXT("\""));
|
||||||
result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(szCustom), &pathSize);
|
result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(szCustom), &pathSize);
|
||||||
if (result == ERROR_SUCCESS) {
|
if (result == ERROR_SUCCESS) {
|
||||||
lstrcat(pszCommand, TEXT(" "));
|
lstrcat(szNotepadExecutableFilename, TEXT(" "));
|
||||||
lstrcat(pszCommand, szCustom);
|
lstrcat(szNotepadExecutableFilename, szCustom);
|
||||||
}
|
}
|
||||||
RegCloseKey(settingKey);
|
RegCloseKey(settingKey);
|
||||||
|
|
||||||
for (UINT i = 0; i < m_cbFiles; i++) {
|
// We have to open the files in batches. A command on the command-line can be at most
|
||||||
DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFilename, MAX_PATH);
|
// 2048 characters in XP and 32768 characters in Win7. In the degenerate case where all
|
||||||
lstrcat(pszCommand, TEXT(" \""));
|
// paths are of length MAX_PATH, we can open at most x files at once, where:
|
||||||
lstrcat(pszCommand, szFilename);
|
// 260 * (x + 2) = 2048 or 32768 <=> x = 5 or x = 124.
|
||||||
lstrcat(pszCommand, TEXT("\""));
|
// Note the +2 to account for the path to notepad++.exe.
|
||||||
}
|
// http://stackoverflow.com/questions/3205027/maximum-length-of-command-line-string
|
||||||
|
|
||||||
STARTUPINFO si;
|
const UINT kiBatchSize = m_winVer > WINVER_XP ? 100 : 4;
|
||||||
PROCESS_INFORMATION pi;
|
|
||||||
ZeroMemory(&si, sizeof(si));
|
UINT iFileIndex = 0;
|
||||||
si.cb = sizeof(si);
|
while(iFileIndex < m_cbFiles) {
|
||||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
memset(pszCommand, 0, bytesRequired);
|
||||||
si.wShowWindow = (WORD)iShowCmd; //SW_RESTORE;
|
lstrcat(pszCommand, szNotepadExecutableFilename);
|
||||||
if (!CreateProcess (NULL, pszCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
for (UINT iBatchSizeCounter = 0; iFileIndex < m_cbFiles && iBatchSizeCounter < kiBatchSize; iBatchSizeCounter++) {
|
||||||
DWORD errorCode = GetLastError();
|
DragQueryFile((HDROP)m_stgMedium.hGlobal, iFileIndex, szFilename, MAX_PATH);
|
||||||
if (errorCode == ERROR_ELEVATION_REQUIRED) { //Fallback to shellexecute
|
lstrcat(pszCommand, TEXT(" \""));
|
||||||
CoInitializeEx(NULL, 0);
|
lstrcat(pszCommand, szFilename);
|
||||||
HINSTANCE execVal = ShellExecute(NULL, TEXT("runas"), pszCommand, NULL, NULL, iShowCmd);
|
lstrcat(pszCommand, TEXT("\""));
|
||||||
CoUninitialize();
|
iFileIndex++;
|
||||||
if (execVal <= (HINSTANCE)32) {
|
}
|
||||||
|
|
||||||
|
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];
|
TCHAR * message = new TCHAR[512+bytesRequired];
|
||||||
wsprintf(message, TEXT("ShellExecute failed (%d): Is this command correct?\r\n%s"), execVal, pszCommand);
|
wsprintf(message, TEXT("Error in CreateProcess (%d): Is this command correct?\r\n%s"), errorCode, pszCommand);
|
||||||
MsgBoxError(message);
|
MsgBoxError(message);
|
||||||
delete [] 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
|
||||||
#define WINVER_VISTA 0x600
|
#define WINVER_VISTA 0x600
|
||||||
|
#define WINVER_XP 0x0501
|
||||||
|
|
||||||
//This is not ideal, but missing from current mingw
|
//This is not ideal, but missing from current mingw
|
||||||
#ifndef ERROR_ELEVATION_REQUIRED
|
#ifndef ERROR_ELEVATION_REQUIRED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user