tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / desktop / win32 / source / QuickStart / QuickStart.cxx
blob3277a6abfe5a8ee873140dc5dc752e1cf7837c52
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
25 #include <windows.h>
26 #include <shellapi.h>
28 #include "resource.h"
29 #include <systools/win32/uwinapi.h>
30 #include <systools/win32/qswin32.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <malloc.h>
35 #include <memory.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( )
45 if ( !SofficeRuns() )
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'\\' );
52 if ( !p )
53 return false;
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);
68 if ( !bSuccess )
69 return false;
71 return true;
73 else
74 return true;
77 int APIENTRY wWinMain(HINSTANCE /*hInstance*/,
78 HINSTANCE /*hPrevInstance*/,
79 LPWSTR /*lpCmdLine*/,
80 int /*nCmdShow*/)
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 );
90 if ( hwndTray )
92 UINT uMsgKillTray = RegisterWindowMessageW( SHUTDOWN_QUICKSTART_MESSAGE );
93 SendMessageW( hwndTray, uMsgKillTray, 0, 0 );
96 return 0;
100 launchSoffice();
101 return 0;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */