MGR: Implement CBOINCClientManager::IsBOINCRunning()for Windows

svn path=/trunk/boinc/; revision=18319
This commit is contained in:
Charlie Fenton 2009-06-07 00:10:32 +00:00
parent 9b099daea7
commit ee77d27727
1 changed files with 21 additions and 31 deletions

View File

@ -118,6 +118,10 @@ bool CBOINCClientManager::IsBOINCCoreRunning() {
#ifdef __WXMSW__
char buf[MAX_PATH] = "";
if (IsBOINCServiceInstalled()) {
running = (FALSE != IsBOINCServiceStarting()) || (FALSE != IsBOINCServiceRunning());
} else {
// Global mutex on Win2k and later
//
if (IsWindows2000Compatible()) {
@ -133,6 +137,7 @@ bool CBOINCClientManager::IsBOINCCoreRunning() {
if (h) {
CloseHandle(h);
}
}
#else
char path[1024];
static FILE_LOCK file_lock;
@ -309,15 +314,6 @@ bool CBOINCClientManager::StartupBOINCCore() {
#ifdef __WXMSW__
// Provide a structure to store process measurements at the time of a
// crash.
typedef struct _BOINC_PROCESS {
DWORD dwProcessId;
DWORD dwParentProcessId;
tstring strProcessName;
} BOINC_PROCESS, *PBOINC_PROCESS;
static tstring downcase_string(tstring& orig) {
tstring retval = orig;
for (size_t i=0; i < retval.length(); i++) {
@ -343,17 +339,11 @@ void CBOINCClientManager::KillClient() {
// Lets start walking the structures to find the good stuff.
pProcesses = (PSYSTEM_PROCESSES)pBuffer;
do {
if (pProcesses->ProcessId) {
BOINC_PROCESS pi;
pi.dwProcessId = pProcesses->ProcessId;
pi.dwParentProcessId = pProcesses->InheritedFromProcessId;
pi.strProcessName = pProcesses->ProcessName.Buffer;
if (downcase_string(pi.strProcessName) == tstring(_T("boinc.exe"))) {
TerminateProcessById(pi.dwProcessId);
tstring strProcessName = pProcesses->ProcessName.Buffer;
if (downcase_string(strProcessName) == tstring(_T("boinc.exe"))) {
TerminateProcessById(pProcesses->ProcessId);
break;
}
}