1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 // QuickStart.cpp : Defines the entry point for the application.
22 #include <sal/config.h>
24 #define WIN32_LEAN_AND_MEAN
29 #include <systools/win32/uwinapi.h>
30 #include <systools/win32/qswin32.h>
37 static bool SofficeRuns()
39 // check for soffice by searching the communication window
40 return FindWindowExW( nullptr, nullptr, QUICKSTART_CLASSNAME
, nullptr ) != nullptr;
43 static bool launchSoffice( )
47 wchar_t filename
[_MAX_PATH
+ 1];
49 filename
[_MAX_PATH
] = 0;
50 GetModuleFileNameW( nullptr, filename
, _MAX_PATH
); // soffice resides in the same dir
51 wchar_t *p
= wcsrchr( filename
, L
'\\' );
55 wcsncpy( p
+1, L
"soffice.exe", _MAX_PATH
- (p
+1 - filename
) );
57 wchar_t imagename
[_MAX_PATH
+ 1];
59 imagename
[_MAX_PATH
] = 0;
60 _snwprintf(imagename
, _MAX_PATH
, L
"\"%s\" --quickstart", filename
);
62 STARTUPINFOW aStartupInfo
;
63 ZeroMemory(&aStartupInfo
, sizeof(aStartupInfo
));
64 aStartupInfo
.cb
= sizeof(aStartupInfo
);
65 aStartupInfo
.wShowWindow
= SW_SHOW
;
66 PROCESS_INFORMATION aProcessInfo
;
67 bool bSuccess
= CreateProcessW(filename
, imagename
, nullptr, nullptr, TRUE
, 0, nullptr, nullptr, &aStartupInfo
, &aProcessInfo
);
77 int APIENTRY
wWinMain(HINSTANCE
/*hInstance*/,
78 HINSTANCE
/*hPrevInstance*/,
82 // Look for --killtray argument
84 for ( int i
= 1; i
< __argc
; i
++ )
86 if ( 0 == wcscmp( __wargv
[i
], L
"--killtray" ) )
88 HWND hwndTray
= FindWindowW( QUICKSTART_CLASSNAME
, nullptr );
92 UINT uMsgKillTray
= RegisterWindowMessageW( SHUTDOWN_QUICKSTART_MESSAGE
);
93 SendMessageW( hwndTray
, uMsgKillTray
, 0, 0 );
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */