From 0aa4cbb7ca6624d277e3eb81e1718d574bc09b50 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Mon, 7 Nov 2005 11:12:51 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=8812 --- checkin_notes | 9 +++++++ client/win/hostinfo_win.cpp | 50 ++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/checkin_notes b/checkin_notes index c8891d83f5..aebae2faed 100755 --- a/checkin_notes +++ b/checkin_notes @@ -13613,3 +13613,12 @@ Rom 7 Nov 2005 locale/client/en_US/ BOINC Manager.po BOINC Manager.mo + +Rom 7 Nov 2005 + - Use GlobalMemoryStatusEx instead of GlobalMemoryStatus so that + we can detect memory sizes larger than 4GB in size. + + client/win/ + hostinfo_win.cpp + + \ No newline at end of file diff --git a/client/win/hostinfo_win.cpp b/client/win/hostinfo_win.cpp index 1f95494e93..b47fbf95be 100755 --- a/client/win/hostinfo_win.cpp +++ b/client/win/hostinfo_win.cpp @@ -28,6 +28,22 @@ HINSTANCE g_hIdleDetectionDll; +// Memory Status Structure for Win2K and WinXP based systems. +typedef struct _MYMEMORYSTATUSEX { + DWORD dwLength; + DWORD dwMemoryLoad; + DWORDLONG ullTotalPhys; + DWORDLONG ullAvailPhys; + DWORDLONG ullTotalPageFile; + DWORDLONG ullAvailPageFile; + DWORDLONG ullTotalVirtual; + DWORDLONG ullAvailVirtual; + DWORDLONG ullAvailExtendedVirtual; +} MYMEMORYSTATUSEX, *LPMYMEMORYSTATUSEX; + +typedef BOOL (WINAPI *MYGLOBALMEMORYSTATUSEX)(LPMYMEMORYSTATUSEX lpBuffer); + + // Returns the number of seconds difference from UTC // int get_timezone(void) { @@ -296,12 +312,34 @@ int HOST_INFO::get_host_info() { timezone = get_timezone(); - MEMORYSTATUS mStatus; - ZeroMemory(&mStatus, sizeof(MEMORYSTATUS)); - mStatus.dwLength = sizeof(MEMORYSTATUS); - GlobalMemoryStatus(&mStatus); - m_nbytes = (double)mStatus.dwTotalPhys; - m_swap = (double)mStatus.dwTotalPageFile; + // Detect the amount of memory the system has with the new API, if it doesn't + // exist, then use the older API. + HMODULE hKernel32; + MYGLOBALMEMORYSTATUSEX myGlobalMemoryStatusEx; + hKernel32 = LoadLibrary("kernel32.dll"); + if (hKernel32) { + myGlobalMemoryStatusEx = (MYGLOBALMEMORYSTATUSEX) GetProcAddress(hKernel32, "GlobalMemoryStatusEx"); + } + + if (hKernel32 && myGlobalMemoryStatusEx) { + MYMEMORYSTATUSEX mStatusEx; + ZeroMemory(&mStatusEx, sizeof(MYMEMORYSTATUSEX)); + mStatusEx.dwLength = sizeof(MYMEMORYSTATUSEX); + (*myGlobalMemoryStatusEx)(&mStatusEx); + m_nbytes = (double)mStatusEx.ullTotalPhys; + m_swap = (double)mStatusEx.ullTotalPageFile; + } else { + MEMORYSTATUS mStatus; + ZeroMemory(&mStatus, sizeof(MEMORYSTATUS)); + mStatus.dwLength = sizeof(MEMORYSTATUS); + GlobalMemoryStatus(&mStatus); + m_nbytes = (double)mStatus.dwTotalPhys; + m_swap = (double)mStatus.dwTotalPageFile; + } + + if (hKernel32) { + FreeLibrary(hKernel32); + } // gets processor vendor name and model name from registry, works for intel char vendorName[256], processorName[256], identifierName[256];