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 #include "launcher.hxx"
23 # define WIN32_LEAN_AND_MEAN
25 #pragma warning(push, 1)
28 # include <shellapi.h>
38 extern "C" int APIENTRY
WinMain( HINSTANCE
, HINSTANCE
, LPSTR
, int )
40 extern "C" int APIENTRY
_tWinMain( HINSTANCE
, HINSTANCE
, LPTSTR
, int )
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(
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
);
104 DWORD dwError
= GetLastError();
109 FORMAT_MESSAGE_ALLOCATE_BUFFER
|
110 FORMAT_MESSAGE_FROM_SYSTEM
,
113 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), // Default language
119 // Display the string.
120 MessageBox( NULL
, (LPCTSTR
)lpMsgBuf
, NULL
, MB_OK
| MB_ICONERROR
);
123 LocalFree( lpMsgBuf
);
125 return GetLastError();
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */