1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=4:tabstop=4:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "nsWinRemoteClient.h"
10 #include "RemoteUtils.h"
11 #include "WinRemoteMessage.h"
13 using namespace mozilla
;
15 nsresult
nsWinRemoteClient::Init() { return NS_OK
; }
17 nsresult
nsWinRemoteClient::SendCommandLine(const char* aProgram
,
18 const char* aProfile
, int32_t argc
,
19 const char** argv
, bool aRaise
) {
21 BuildClassName(aProgram
, aProfile
, className
);
23 HWND handle
= ::FindWindowW(className
.get(), 0);
26 return NS_ERROR_NOT_AVAILABLE
;
30 _wgetcwd(cwd
, MAX_PATH
);
31 WinRemoteMessageSender
sender(argc
, argv
, nsDependentString(cwd
));
34 // Because we are the running process we have permission to raise the target
35 // instance to the foreground. We can do so for the hidden message window as
36 // we have its handle here. The target instance is then able to raise any
37 // window it chooses to as part of handling the command line.
38 ::SetForegroundWindow(handle
);
40 ::SendMessageW(handle
, WM_COPYDATA
, 0,
41 reinterpret_cast<LPARAM
>(sender
.CopyData()));