@@ -124,44 +124,48 @@ IFACEMETHODIMP BaseNppExplorerCommandHandler::Invoke(IShellItemArray* psiItemArr
124124 RETURN_IF_FAILED (psiItemArray->GetCount (&count));
125125
126126 IShellItem* psi = nullptr ;
127- LPWSTR itemName;
127+ LPWSTR file2OpenPath;
128+
129+ wstring appPath = L" \" " ;
130+ appPath += GetNppExecutableFullPath ().c_str ();
131+ appPath += L" \" " ;
132+
133+ wstring filePathsArg = appPath;
134+ filePathsArg += L" " ;
128135
129136 for (DWORD i = 0 ; i < count; ++i)
130137 {
131138 psiItemArray->GetItemAt (i, &psi);
132- RETURN_IF_FAILED (psi->GetDisplayName (SIGDN_FILESYSPATH, &itemName));
139+ RETURN_IF_FAILED (psi->GetDisplayName (SIGDN_FILESYSPATH, &file2OpenPath));
140+ // Release the IShellItem pointer, since we are done with it as well.
141+ psi->Release ();
133142
134- const wstring applicationName = GetNppExecutableFullPath ();
135- const wstring commandLine = GetCommandLine (itemName);
143+ filePathsArg += L" \" " ;
144+ filePathsArg += file2OpenPath;
145+ filePathsArg += L" \" " ;
136146
137147 // Cleanup itemName, since we are done with it.
138- if (itemName )
148+ if (file2OpenPath )
139149 {
140- CoTaskMemFree (itemName );
150+ CoTaskMemFree (file2OpenPath );
141151 }
152+ }
142153
143- // Release the IShellItem pointer, since we are done with it as well.
144- psi->Release ();
145-
146- STARTUPINFO si;
147- PROCESS_INFORMATION pi;
148-
149- ZeroMemory (&si, sizeof (si));
150- si.cb = sizeof (si);
151- ZeroMemory (&pi, sizeof (pi));
152-
153- wchar_t * application = (LPWSTR)applicationName.c_str ();
154- wchar_t * command = (LPWSTR)commandLine.c_str ();
154+ STARTUPINFO si;
155+ PROCESS_INFORMATION pi;
155156
156- if (!CreateProcessW (application, command, nullptr , nullptr , false , CREATE_NEW_PROCESS_GROUP, nullptr , nullptr , &si, &pi))
157- {
158- return S_OK;
159- }
157+ ZeroMemory (&si, sizeof (si));
158+ si.cb = sizeof (si);
159+ ZeroMemory (&pi, sizeof (pi));
160160
161- CloseHandle (pi.hProcess );
162- CloseHandle (pi.hThread );
161+ if (!CreateProcessW (GetNppExecutableFullPath ().c_str (), (LPWSTR)filePathsArg.c_str (), nullptr , nullptr , false , CREATE_NEW_PROCESS_GROUP, nullptr , nullptr , &si, &pi))
162+ {
163+ return S_OK;
163164 }
164165
166+ CloseHandle (pi.hProcess );
167+ CloseHandle (pi.hThread );
168+
165169 return S_OK;
166170}
167171CATCH_RETURN ();
0 commit comments