From 52cdd2188a87319d7a2cca28090d376e2b4a1397 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 19 Jan 2004 19:14:59 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2909 --- api/windows_opengl.C | 7 ++----- checkin_notes | 14 ++++++++++++++ client/app.C | 18 +++--------------- client/win/win_util.h | 31 ++++++++++++++++++++++++------- lib/util.C | 15 +++++++++++++++ 5 files changed, 58 insertions(+), 27 deletions(-) diff --git a/api/windows_opengl.C b/api/windows_opengl.C index 6142cef575..0797b6dc21 100755 --- a/api/windows_opengl.C +++ b/api/windows_opengl.C @@ -22,6 +22,7 @@ #include "graphics_api.h" #include "app_ipc.h" #include "util.h" +#include "win_util.h" //#include "win_idle_tracker.h" //remove if there are windows problems @@ -171,10 +172,6 @@ void SetMode(int mode) { KillWindow(); - FILE* f = fopen("setmode.txt", "a"); - fprintf(f, "mode: %d\n", mode); - fclose(f); - current_graphics_mode = mode; if (mode != MODE_HIDE_GRAPHICS) { @@ -318,7 +315,7 @@ static VOID CALLBACK timer_handler(HWND, UINT, UINT, DWORD) { DWORD WINAPI win_graphics_event_loop( LPVOID gi ) { MSG msg; // Windows Message Structure - m_uEndSSMsg = RegisterWindowMessage(END_SS_MSG); + m_uEndSSMsg = RegisterWindowMessage(STOP_SS_MSG); // Register window class and graphics mode message reg_win_class(); diff --git a/checkin_notes b/checkin_notes index 3fc81f92d4..422c043789 100755 --- a/checkin_notes +++ b/checkin_notes @@ -9356,3 +9356,17 @@ David Jan 18 2004 sched/ file_upload_handler.C handle_request.C + +David Jan 19 2004 + - use STOP_SS_MSG symbol instead of END_SS_MSG + (these redundantly refered to the same string) + - fixed buggy error-handling code for Win CreateProcess() + + api/ + windows_opengl.C + client/ + app.C + win/ + win_util.h + lib/util.C + diff --git a/client/app.C b/client/app.C index 1db5acdaef..9546bf90b8 100644 --- a/client/app.C +++ b/client/app.C @@ -345,7 +345,6 @@ int ACTIVE_TASK::start(bool first_time) { STARTUPINFO startup_info; char slotdirpath[256]; char cmd_line[512]; - int win_error; memset( &process_info, 0, sizeof( process_info ) ); memset( &startup_info, 0, sizeof( startup_info ) ); @@ -379,22 +378,11 @@ int ACTIVE_TASK::start(bool first_time) { &startup_info, &process_info )) { - win_error = GetLastError(); - char *errorargs[] = {app_version->app_name,"","","",""}; - LPVOID lpMsgBuf; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, - NULL, win_error, 0, (LPTSTR)&lpMsgBuf, 0, errorargs - ); - state = PROCESS_COULDNT_START; result->active_task_state = PROCESS_COULDNT_START; - if (win_error) { - gstate.report_result_error(*result, win_error, "CreateProcess(): %s", (LPTSTR)&lpMsgBuf); - LocalFree(lpMsgBuf); - return ERR_EXEC; - } - msg_printf(wup->project, MSG_ERROR, "CreateProcess: %s", (LPCTSTR)lpMsgBuf); - LocalFree(lpMsgBuf); + gstate.report_result_error(*result, ERR_EXEC, "CreateProcess() failed"); + msg_printf(wup->project, MSG_ERROR, "CreateProcess() failed"); + return ERR_EXEC; } pid = process_info.dwProcessId; pid_handle = process_info.hProcess; diff --git a/client/win/win_util.h b/client/win/win_util.h index 91405a22d0..ac1e42892c 100755 --- a/client/win/win_util.h +++ b/client/win/win_util.h @@ -1,11 +1,28 @@ +// The contents of this file are subject to the BOINC Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://boinc.berkeley.edu/license_1.0.txt +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// -// function declarations -int UtilGetRegKey(char *name, DWORD &keyval); -int UtilSetRegKey(char *name, DWORD value); -int UtilGetRegStr(char *name, char *str); -int UtilSetRegStr(char *name, char *str); -int UtilSetRegStartupStr(char *name, char *str); -int UtilInitOSVersion( void ); +extern int UtilGetRegKey(char *name, DWORD &keyval); +extern int UtilSetRegKey(char *name, DWORD value); +extern int UtilGetRegStr(char *name, char *str); +extern int UtilSetRegStr(char *name, char *str); +extern int UtilSetRegStartupStr(char *name, char *str); +extern int UtilInitOSVersion( void ); #define START_SS_MSG "BOINC_SS_START" #define STOP_SS_MSG "BOINC_SS_END" diff --git a/lib/util.C b/lib/util.C index 434af93dd9..27930e8f10 100755 --- a/lib/util.C +++ b/lib/util.C @@ -504,3 +504,18 @@ int read_file_string(const char* pathname, string& result) { while (f.get(c)) result += c; return 0; } + +#ifdef _WIN32 +// the following doesn't seem to work +// TODO: fix it; use after e.g. CreateProcess() error +// +void windows_error_string(char* buf, int len) { + strcpy(buf, ""); + LPVOID lpMsgBuf; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, NULL + ); + safe_strncpy(buf, (LPCSTR)lpMsgBuf, len); + LocalFree(lpMsgBuf); +} +#endif \ No newline at end of file