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