1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// Windows/System.cpp 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "StdAfx.h" 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "../Common/Defs.h" 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "System.h" 8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 9baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NWindows { 10baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NSystem { 11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 12baa3858d3f5d128a5c8466b700098109edcad5f2repo syncUInt32 GetNumberOfProcessors() 13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 14baa3858d3f5d128a5c8466b700098109edcad5f2repo sync SYSTEM_INFO systemInfo; 15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync GetSystemInfo(&systemInfo); 16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return (UInt32)systemInfo.dwNumberOfProcessors; 17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#ifndef UNDER_CE 20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#if !defined(_WIN64) && defined(__GNUC__) 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 23baa3858d3f5d128a5c8466b700098109edcad5f2repo synctypedef struct _MY_MEMORYSTATUSEX { 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORD dwLength; 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORD dwMemoryLoad; 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORDLONG ullTotalPhys; 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORDLONG ullAvailPhys; 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORDLONG ullTotalPageFile; 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORDLONG ullAvailPageFile; 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORDLONG ullTotalVirtual; 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORDLONG ullAvailVirtual; 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync DWORDLONG ullAvailExtendedVirtual; 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} MY_MEMORYSTATUSEX, *MY_LPMEMORYSTATUSEX; 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#else 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 37baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define MY_MEMORYSTATUSEX MEMORYSTATUSEX 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#define MY_LPMEMORYSTATUSEX LPMEMORYSTATUSEX 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif 41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 42baa3858d3f5d128a5c8466b700098109edcad5f2repo synctypedef BOOL (WINAPI *GlobalMemoryStatusExP)(MY_LPMEMORYSTATUSEX lpBuffer); 43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#endif 45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 46baa3858d3f5d128a5c8466b700098109edcad5f2repo syncUInt64 GetRamSize() 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef UNDER_CE 49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync MY_MEMORYSTATUSEX stat; 50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync stat.dwLength = sizeof(stat); 51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifdef _WIN64 53baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (!::GlobalMemoryStatusEx(&stat)) 54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return 0; 55baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys); 56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #else 57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef UNDER_CE 58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP) 59baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GlobalMemoryStatusEx"); 60baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (globalMemoryStatusEx != 0 && globalMemoryStatusEx(&stat)) 61baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys); 62baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 63baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 64baa3858d3f5d128a5c8466b700098109edcad5f2repo sync MEMORYSTATUS stat; 65baa3858d3f5d128a5c8466b700098109edcad5f2repo sync stat.dwLength = sizeof(stat); 66baa3858d3f5d128a5c8466b700098109edcad5f2repo sync ::GlobalMemoryStatus(&stat); 67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return MyMin(stat.dwTotalVirtual, stat.dwTotalPhys); 68baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 69baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 70baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 72baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}} 73