2005-03-03 11:08:38 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
2007-10-09 11:35:47 +00:00
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-03-03 11:08:38 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "boinccas.h"
|
2007-02-17 20:56:16 +00:00
|
|
|
#ifdef _UNICODE
|
2007-02-12 21:41:48 +00:00
|
|
|
#include "terminate.h"
|
2007-02-17 20:56:16 +00:00
|
|
|
#endif
|
2005-03-03 11:08:38 +00:00
|
|
|
#include "CAShutdownBOINCManager.h"
|
|
|
|
|
|
|
|
#define CUSTOMACTION_NAME _T("CAShutdownBOINCManager")
|
|
|
|
#define CUSTOMACTION_PROGRESSTITLE _T("Shutting down running instances of BOINC Manager")
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Function:
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
CAShutdownBOINCManager::CAShutdownBOINCManager(MSIHANDLE hMSIHandle) :
|
|
|
|
BOINCCABase(hMSIHandle, CUSTOMACTION_NAME, CUSTOMACTION_PROGRESSTITLE)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Function:
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
CAShutdownBOINCManager::~CAShutdownBOINCManager()
|
|
|
|
{
|
|
|
|
BOINCCABase::~BOINCCABase();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Function:
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
UINT CAShutdownBOINCManager::OnExecution()
|
|
|
|
{
|
|
|
|
HWND hWndBOINCManagerSystray = NULL;
|
|
|
|
TCHAR szWindowTitle[256];
|
|
|
|
LRESULT lrReturnValue = NULL;
|
|
|
|
UINT uiLoopCounter = 0;
|
|
|
|
UINT uiReturn = -1;
|
|
|
|
|
|
|
|
const UINT WM_TASKBARSHUTDOWN = ::RegisterWindowMessage(_T("TaskbarShutdown"));
|
|
|
|
|
2008-07-18 18:01:58 +00:00
|
|
|
#ifdef _UNICODE
|
2013-11-04 15:50:23 +00:00
|
|
|
TerminateProcessEx( tstring(_T("boincmgr.exe")), false );
|
|
|
|
TerminateProcessEx( tstring(_T("charityengine.exe")), false );
|
|
|
|
TerminateProcessEx( tstring(_T("gridrepublic.exe")), false );
|
|
|
|
TerminateProcessEx( tstring(_T("progressthruprocessors.exe")), false );
|
2008-07-18 18:01:58 +00:00
|
|
|
#endif
|
|
|
|
|
2005-03-03 11:08:38 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
hWndBOINCManagerSystray = FindWindow( _T("wxTaskBarExWindowClass"), _T("BOINCManagerSystray") );
|
|
|
|
if ( NULL != hWndBOINCManagerSystray )
|
|
|
|
{
|
|
|
|
GetWindowText( hWndBOINCManagerSystray, szWindowTitle, (sizeof(szWindowTitle) * sizeof(TCHAR)));
|
|
|
|
LogProgress( szWindowTitle );
|
|
|
|
|
|
|
|
lrReturnValue = SendMessage( hWndBOINCManagerSystray, WM_TASKBARSHUTDOWN, NULL, NULL );
|
|
|
|
if ( 0 != lrReturnValue )
|
|
|
|
{
|
|
|
|
LogMessage(
|
2006-06-22 02:26:22 +00:00
|
|
|
INSTALLMESSAGE_INFO,
|
2005-03-03 11:08:38 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(int)lrReturnValue,
|
|
|
|
_T("Setup was unable to shutdown the BOINC Manager Systray window.")
|
|
|
|
);
|
|
|
|
return ERROR_INSTALL_FAILURE;
|
|
|
|
}
|
|
|
|
Sleep(1000);
|
|
|
|
}
|
|
|
|
uiLoopCounter++;
|
|
|
|
}
|
2008-06-18 17:17:04 +00:00
|
|
|
while ( (NULL != hWndBOINCManagerSystray) && ( 5 >= uiLoopCounter ) );
|
2005-03-03 11:08:38 +00:00
|
|
|
|
|
|
|
if ( NULL != hWndBOINCManagerSystray )
|
|
|
|
{
|
|
|
|
LogMessage(
|
2006-06-22 02:26:22 +00:00
|
|
|
INSTALLMESSAGE_INFO,
|
2005-03-03 11:08:38 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
uiLoopCounter,
|
2007-02-12 21:41:48 +00:00
|
|
|
_T("One or more BOINC Manager applications could not be closed, terminating process(s).")
|
2005-03-03 11:08:38 +00:00
|
|
|
);
|
2007-02-12 21:41:48 +00:00
|
|
|
|
2005-03-03 11:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Function: ShutdownBOINCManager
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
UINT __stdcall ShutdownBOINCManager(MSIHANDLE hInstall)
|
|
|
|
{
|
|
|
|
UINT uiReturnValue = 0;
|
|
|
|
|
|
|
|
CAShutdownBOINCManager* pCA = new CAShutdownBOINCManager(hInstall);
|
|
|
|
uiReturnValue = pCA->Execute();
|
|
|
|
delete pCA;
|
|
|
|
|
|
|
|
return uiReturnValue;
|
|
|
|
}
|