Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / setup_native / source / win32 / customactions / quickstarter / shutdown_quickstart.cxx
blobaa9316c5cb017590642e6486b43856472b3196f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "quickstarter.hxx"
30 #include <systools/win32/qswin32.h>
32 static BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
34 MSIHANDLE hMSI = static_cast< MSIHANDLE >( lParam );
35 CHAR szClassName[sizeof(QUICKSTART_CLASSNAMEA) + 1];
37 int nCharsCopied = GetClassName( hWnd, szClassName, sizeof( szClassName ) );
39 if ( nCharsCopied && !stricmp( QUICKSTART_CLASSNAMEA, szClassName ) )
41 DWORD dwProcessId;
43 if ( GetWindowThreadProcessId( hWnd, &dwProcessId ) )
45 std::string sImagePath = GetProcessImagePath( dwProcessId );
46 std::string sOfficeImageDir = GetOfficeInstallationPath( hMSI ) + "program\\";
48 if ( !strnicmp( sImagePath.c_str(), sOfficeImageDir.c_str(), sOfficeImageDir.length() ) )
50 UINT uMsgShutdownQuickstart = RegisterWindowMessageA( SHUTDOWN_QUICKSTART_MESSAGEA );
52 if ( uMsgShutdownQuickstart )
53 SendMessageA( hWnd, uMsgShutdownQuickstart, 0, 0 );
56 HANDLE hProcess = OpenProcess( SYNCHRONIZE, FALSE, dwProcessId );
58 if ( hProcess )
60 WaitForSingleObject( hProcess, 30000 ); // Wait at most 30 seconds for process to terminate
61 CloseHandle( hProcess );
64 return FALSE;
70 return TRUE;
74 extern "C" UINT __stdcall ShutDownQuickstarter( MSIHANDLE hMSI )
76 EnumWindows( EnumWindowsProc, hMSI );
78 return ERROR_SUCCESS;
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */