diff --git a/client/client_state.C b/client/client_state.C index 1f63258fc9..a5c37699a6 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -68,6 +68,7 @@ CLIENT_STATE::CLIENT_STATE() { app_started = 0; max_transfer_rate = 9999999; max_bytes = 0; + minimize = false; user_idle = true; use_proxy = false; proxy_server_name[0] = 0; @@ -1002,6 +1003,12 @@ void CLIENT_STATE::parse_cmdline(int argc, char** argv) { max_transfer_rate = atoi(argv[++i]); continue; }; + + // Put the client in the background after starting up + if (!strcmp(argv[i], "-min")) { + minimize = true; + continue; + }; } if ((p = getenv("HTTP_PROXY"))) { diff --git a/client/client_state.h b/client/client_state.h index 8f35c464e4..29f9943fd4 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -78,6 +78,7 @@ public: // returns the total disk usage of BOINC on this host int allowed_disk_usage(double&); unsigned int giveup_after; + bool minimize; // put client in the background after it's started up bool user_idle; bool suspend_requested; bool use_proxy; diff --git a/client/win/hostinfo_win.cpp b/client/win/hostinfo_win.cpp index 3c6d3cb945..26de9f12ae 100755 --- a/client/win/hostinfo_win.cpp +++ b/client/win/hostinfo_win.cpp @@ -142,16 +142,16 @@ int get_host_info(HOST_INFO& host) { case PROCESSOR_ARCHITECTURE_INTEL: switch ( SystemInfo.dwProcessorType ) { case PROCESSOR_INTEL_386: - strcpy( host.p_model, "Intel 80386" ); + strcpy( host.p_model, "80386" ); break; case PROCESSOR_INTEL_486: - strcpy( host.p_model, "Intel 80486" ); + strcpy( host.p_model, "80486" ); break; case PROCESSOR_INTEL_PENTIUM: - strcpy( host.p_model, "Intel Pentium" ); + strcpy( host.p_model, "Pentium" ); break; default: - strcpy( host.p_model, "Intel x86" ); + strcpy( host.p_model, "x86" ); break; } break; diff --git a/client/win/wingui.cpp b/client/win/wingui.cpp index e63f243d48..43e978e8d1 100755 --- a/client/win/wingui.cpp +++ b/client/win/wingui.cpp @@ -20,9 +20,11 @@ // include header #include "wingui.h" +#include "util.h" // globals +int OSVersion; CMainWindow* g_myWnd = NULL; CMyApp g_myApp; char* g_szColumnTitles[MAX_LIST_ID][MAX_COLS] = { @@ -1251,7 +1253,11 @@ BOOL CMyApp::InitInstance() return FALSE; } m_pMainWnd = new CMainWindow(); - m_pMainWnd->ShowWindow(SW_SHOW); + if (gstate.minimize) + m_pMainWnd->ShowWindow(SW_HIDE); + else + m_pMainWnd->ShowWindow(SW_SHOW); + m_pMainWnd->UpdateWindow(); return TRUE; } @@ -1757,7 +1763,7 @@ void CMainWindow::LoadUserSettings() rt.right = nBuf + rt.left; nBuf = GetPrivateProfileInt("WINDOW", "height", 400, szPath); rt.bottom = nBuf + rt.top; - SetWindowPos(&wndNoTopMost, rt.left, rt.top, rt.Width(), rt.Height(), SWP_SHOWWINDOW); + SetWindowPos(&wndNoTopMost, rt.left, rt.top, rt.Width(), rt.Height(), gstate.minimize?SWP_HIDEWINDOW:SWP_SHOWWINDOW); // load selected tab nBuf = GetPrivateProfileInt("WINDOW", "selection", 0, szPath); @@ -2204,6 +2210,8 @@ void CMainWindow::OnCommandExit() // windows, and initializes client state and timer int CMainWindow::OnCreate(LPCREATESTRUCT lpcs) { + char curDir[512]; + if (CWnd::OnCreate(lpcs) == -1) { return -1; } @@ -2299,6 +2307,14 @@ int CMainWindow::OnCreate(LPCREATESTRUCT lpcs) m_TabCtrl.SetFont(&m_Font); m_UsagePieCtrl.SetFont(&m_Font); + // Determine the OS version + UtilInitOSVersion(); + + // Set the current directory to the default + UtilGetRegStr("ClientDir", curDir); + if (strlen(curDir)) + SetCurrentDirectory(curDir); + // add status icon to taskbar SetStatusIcon(ICON_NORMAL); @@ -2308,8 +2324,18 @@ int CMainWindow::OnCreate(LPCREATESTRUCT lpcs) // Redirect stdout and stderr to files freopen(STDOUT_FILE_NAME, "w", stdout); freopen(STDERR_FILE_NAME, "w", stderr); + // Check what (if any) activities should be logged read_log_flags(); + + LPSTR command_line; + char* argv[100]; + int argc; + + command_line = GetCommandLine(); + argc = parse_command_line( command_line, argv ); + gstate.parse_cmdline(argc, argv); + int retval = gstate.init(); if (retval) { OnCommandExit(); @@ -2834,3 +2860,59 @@ void CProxyDialog::OnOK() gstate.proxy_server_port = atoi(strbuf.GetBuffer(0)); CDialog::OnOK(); } + +////////// +// Function: UtilGetRegStr +// arguments: name: name of key, str: where to store value of key +// returns: int indicating error +// function: reads string value in specified key +int UtilGetRegStr(char *name, char *str ) +{ + LONG error; + DWORD type = REG_SZ; + DWORD size = 128; + HKEY boinc_key; + + if ( OSVersion == OS_WIN95 ) { + error = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\BOINC", + 0, KEY_ALL_ACCESS, &boinc_key ); + if ( error != ERROR_SUCCESS ) return -1; + } else { + error = RegOpenKeyEx( HKEY_CURRENT_USER, "SOFTWARE\\BOINC", + 0, KEY_ALL_ACCESS, &boinc_key ); + if ( error != ERROR_SUCCESS ) return -1; + } + + error = RegQueryValueEx( boinc_key, name, NULL, + &type, (BYTE*)str, &size ); + + RegCloseKey( boinc_key ); + + if ( error != ERROR_SUCCESS ) return -1; + + return 0; +} + +////////// +// Function: UtilInitOSVersion +// arguments: void +// returns: int indicating error +// function: sets global variable "OSVersion" to the current OS (Win95/NT/Unknown) +int UtilInitOSVersion( void ) +{ + OSVERSIONINFO osinfo; + + osinfo.dwOSVersionInfoSize = sizeof(osinfo); + if (!GetVersionEx( &osinfo )) + return FALSE; + + if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + OSVersion = OS_WIN95; + else if ( osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) + OSVersion = OS_WINNT; + else + OSVersion = OS_UNKNOWN; + + return TRUE; + +} diff --git a/client/win/wingui.h b/client/win/wingui.h index cceb83e7cc..5234e09750 100755 --- a/client/win/wingui.h +++ b/client/win/wingui.h @@ -88,6 +88,10 @@ #define MESSAGE_COLS 3 #define MAX_COLS 7 +#define OS_UNKNOWN 0 +#define OS_WIN95 1 +#define OS_WINNT 2 + // typedefs typedef BOOL (CALLBACK* InitFn)(); @@ -333,6 +337,10 @@ protected: DECLARE_MESSAGE_MAP() }; +// function declarations +int UtilGetRegStr(char *name, char *str ); +int UtilInitOSVersion( void ); + // globals extern CMyApp g_myApp;