tdf#133368: update extensions website URLs and use https
[LibreOffice.git] / setup_native / source / win32 / customactions / quickstarter / shutdown_quickstart.cxx
blobc93b000e4b5862a74d9ea542dc2a40f324ff0c7f
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 "quickstarter.hxx"
22 #include <systools/win32/qswin32.h>
24 static BOOL CALLBACK EnumWindowsProc( HWND hWnd, LPARAM lParam )
26 MSIHANDLE hMSI = static_cast< MSIHANDLE >( lParam );
27 WCHAR szClassName[sizeof(QUICKSTART_CLASSNAME)/sizeof(WCHAR) + 1];
29 int nCharsCopied = GetClassNameW( hWnd, szClassName, sizeof(szClassName)/sizeof(szClassName[0]) );
31 if ( nCharsCopied && !_wcsicmp( QUICKSTART_CLASSNAME, szClassName ) )
33 DWORD dwProcessId;
35 if ( GetWindowThreadProcessId( hWnd, &dwProcessId ) )
37 std::wstring sImagePath = GetProcessImagePathW( dwProcessId );
38 std::wstring sOfficeImageDir = GetOfficeInstallationPathW( hMSI ) + L"program\\";
40 if ( !_wcsnicmp( sImagePath.c_str(), sOfficeImageDir.c_str(), sOfficeImageDir.length() ) )
42 UINT uMsgShutdownQuickstart = RegisterWindowMessageW( SHUTDOWN_QUICKSTART_MESSAGE );
44 if ( uMsgShutdownQuickstart )
45 SendMessageW( hWnd, uMsgShutdownQuickstart, 0, 0 );
48 HANDLE hProcess = OpenProcess( SYNCHRONIZE, FALSE, dwProcessId );
50 if ( hProcess )
52 WaitForSingleObject( hProcess, 30000 ); // Wait at most 30 seconds for process to terminate
53 CloseHandle( hProcess );
56 return FALSE;
62 return TRUE;
66 extern "C" __declspec(dllexport) UINT __stdcall ShutDownQuickstarter( MSIHANDLE hMSI )
68 EnumWindows( EnumWindowsProc, hMSI );
70 return ERROR_SUCCESS;
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */