fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / desktop / win32 / source / applauncher / launcher.cxx
blob8c61a3ccfcee9809933012265c686d9a2a82cc34
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 #include "launcher.hxx"
22 #ifndef _WINDOWS_
23 # define WIN32_LEAN_AND_MEAN
24 #if defined _MSC_VER
25 #pragma warning(push, 1)
26 #endif
27 # include <windows.h>
28 # include <shellapi.h>
29 #if defined _MSC_VER
30 #pragma warning(pop)
31 #endif
32 #endif
34 #include <stdlib.h>
35 #include <malloc.h>
37 #ifdef __MINGW32__
38 extern "C" int APIENTRY WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
39 #else
40 extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
41 #endif
43 // Retrieve startup info
45 STARTUPINFO aStartupInfo;
47 ZeroMemory( &aStartupInfo, sizeof(aStartupInfo) );
48 aStartupInfo.cb = sizeof( aStartupInfo );
49 GetStartupInfo( &aStartupInfo );
51 // Retrieve command line
53 LPTSTR lpCommandLine = GetCommandLine();
56 lpCommandLine = (LPTSTR)_alloca( sizeof(_TCHAR) * (_tcslen(lpCommandLine) + _tcslen(APPLICATION_SWITCH) + 2) );
58 _tcscpy( lpCommandLine, GetCommandLine() );
59 _tcscat( lpCommandLine, _T(" ") );
60 _tcscat( lpCommandLine, APPLICATION_SWITCH );
64 // Calculate application name
66 TCHAR szApplicationName[MAX_PATH];
67 TCHAR szDrive[MAX_PATH];
68 TCHAR szDir[MAX_PATH];
69 TCHAR szFileName[MAX_PATH];
70 TCHAR szExt[MAX_PATH];
72 GetModuleFileName( NULL, szApplicationName, MAX_PATH );
73 _tsplitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
74 _tmakepath( szApplicationName, szDrive, szDir, OFFICE_IMAGE_NAME, _T(".exe") );
77 PROCESS_INFORMATION aProcessInfo;
79 BOOL fSuccess = CreateProcess(
80 szApplicationName,
81 lpCommandLine,
82 NULL,
83 NULL,
84 TRUE,
86 NULL,
87 NULL,
88 &aStartupInfo,
89 &aProcessInfo );
91 if ( fSuccess )
93 // Wait for soffice process to be terminated to allow other applications
94 // to wait for termination of started process
96 WaitForSingleObject( aProcessInfo.hProcess, INFINITE );
98 CloseHandle( aProcessInfo.hProcess );
99 CloseHandle( aProcessInfo.hThread );
101 return 0;
104 DWORD dwError = GetLastError();
106 LPVOID lpMsgBuf;
108 FormatMessage(
109 FORMAT_MESSAGE_ALLOCATE_BUFFER |
110 FORMAT_MESSAGE_FROM_SYSTEM,
111 NULL,
112 dwError,
113 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
114 (LPTSTR)&lpMsgBuf,
116 NULL
119 // Display the string.
120 MessageBox( NULL, (LPCTSTR)lpMsgBuf, NULL, MB_OK | MB_ICONERROR );
122 // Free the buffer.
123 LocalFree( lpMsgBuf );
125 return GetLastError();
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */