@@ -193,33 +193,35 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
193193
194194 // Determine if we should use an already running instance of Brackets.
195195 HANDLE hMutex = ::OpenMutex (MUTEX_ALL_ACCESS, FALSE , FIRST_INSTANCE_MUTEX_NAME);
196- if (( hMutex != NULL ) && AppGetCommandLine ()-> HasArguments () && (lpCmdLine != NULL ) ) {
197- // for subsequent instances, re-use an already running instance if we're being called to
198- // open an existing file on the command-line (eg. Open With.. from Windows Explorer)
199- HWND hFirstInstanceWnd = cef_main_window::FindFirstTopLevelInstance ();
200- if (hFirstInstanceWnd != NULL ) {
201- ::SetForegroundWindow (hFirstInstanceWnd);
202- if (::IsIconic (hFirstInstanceWnd))
203- ::ShowWindow (hFirstInstanceWnd, SW_RESTORE);
204-
205- // message the other Brackets instance to actually open the given filename
206- std::wstring filename = lpCmdLine;
207- std::wstring wstrFilename ;
208- // We check if this is a valid file path. If not just ignore this parameter.
209- if ( GetFullPath (filename, wstrFilename)) {
210- ConvertToUnixPath ( wstrFilename);
211- // note: WM_COPYDATA will manage passing the string across process space
212- COPYDATASTRUCT data;
213- data. dwData = ID_WM_COPYDATA_SENDOPENFILECOMMAND ;
214- data.cbData = (wstrFilename. length () + 1 ) * sizeof (WCHAR) ;
215- data.lpData = (LPVOID) wstrFilename.c_str ( );
216- ::SendMessage (hFirstInstanceWnd, WM_COPYDATA, (WPARAM)(HWND)hFirstInstanceWnd, (LPARAM)( LPVOID)&data );
217- // exit this instance
218- return 0 ;
196+ if (hMutex != NULL ) {
197+ // for subsequent instances, re-use an already running instance if we're being called to
198+ // open an existing file on the command-line (eg. Open With.. from Windows Explorer)
199+ HWND hFirstInstanceWnd = cef_main_window::FindFirstTopLevelInstance ();
200+ if (hFirstInstanceWnd != NULL ) {
201+ ::SetForegroundWindow (hFirstInstanceWnd);
202+ if (::IsIconic (hFirstInstanceWnd))
203+ ::ShowWindow (hFirstInstanceWnd, SW_RESTORE);
204+ // Check for arguments. If any pass it to the existing running instance.
205+ if ( AppGetCommandLine ()-> HasArguments () && (lpCmdLine != NULL ) ){
206+ // message the other Brackets instance to actually open the given filename
207+ std::wstring filename = lpCmdLine ;
208+ std::wstring wstrFilename;
209+ // We check if this is a valid file path. If not just ignore this parameter.
210+ if ( GetFullPath (filename, wstrFilename)) {
211+ ConvertToUnixPath (wstrFilename);
212+ // note: WM_COPYDATA will manage passing the string across process space
213+ COPYDATASTRUCT data ;
214+ data.dwData = ID_WM_COPYDATA_SENDOPENFILECOMMAND ;
215+ data.cbData = (wstrFilename.length () + 1 ) * sizeof (WCHAR );
216+ data. lpData = ( LPVOID)wstrFilename. c_str ( );
217+ ::SendMessage (hFirstInstanceWnd, WM_COPYDATA, (WPARAM)(HWND)hFirstInstanceWnd, (LPARAM)(LPVOID)&data);
218+ }
219219 }
220+ // exit this instance
221+ return 0 ;
220222 }
221223 // otherwise, fall thru and launch a new instance
222- }
224+ }
223225
224226 if (hMutex == NULL ) {
225227 // first instance of this app, so create the mutex and continue execution of this instance.
0 commit comments