1 /* 2 * MEMORY.C - internal command. 3 * 4 * 5 * History: 6 * 7 * 01-Sep-1999 (Eric Kohl) 8 * Started. 9 * 10 * 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>) 11 * Remove all hardcoded strings in En.rc 12 */ 13 14 #include "precomp.h" 15 16 #ifdef INCLUDE_CMD_MEMORY 17 18 INT CommandMemory (LPTSTR param) 19 { 20 MEMORYSTATUSEX msex; 21 TCHAR szMemoryLoad[20]; 22 TCHAR szTotalPhys[40]; 23 TCHAR szAvailPhys[40]; 24 TCHAR szTotalPageFile[40]; 25 TCHAR szAvailPageFile[40]; 26 TCHAR szTotalVirtual[40]; 27 TCHAR szAvailVirtual[40]; 28 BOOL (WINAPI *GlobalMemoryStatusEx)(LPMEMORYSTATUSEX); 29 30 if (!_tcsncmp (param, _T("/?"), 2)) 31 { 32 ConOutResPaging(TRUE,STRING_MEMORY_HELP1); 33 return 0; 34 } 35 36 GlobalMemoryStatusEx 37 = (BOOL (WINAPI *)(LPMEMORYSTATUSEX))GetProcAddress(GetModuleHandle(_T("KERNEL32")), "GlobalMemoryStatusEx"); 38 if (GlobalMemoryStatusEx) 39 { 40 msex.dwLength = sizeof(MEMORYSTATUSEX); 41 GlobalMemoryStatusEx(&msex); 42 } 43 else 44 { 45 MEMORYSTATUS ms; 46 ms.dwLength = sizeof(MEMORYSTATUS); 47 GlobalMemoryStatus(&ms); 48 msex.dwMemoryLoad = ms.dwMemoryLoad; 49 msex.ullTotalPhys = ms.dwTotalPhys; 50 msex.ullAvailPhys = ms.dwAvailPhys; 51 msex.ullTotalPageFile = ms.dwTotalPageFile; 52 msex.ullAvailPageFile = ms.dwAvailPageFile; 53 msex.ullTotalVirtual = ms.dwTotalVirtual; 54 msex.ullAvailVirtual = ms.dwAvailVirtual; 55 } 56 57 ConvertULargeInteger(msex.dwMemoryLoad, szMemoryLoad, 20, FALSE); 58 ConvertULargeInteger(msex.ullTotalPhys, szTotalPhys, 40, TRUE); 59 ConvertULargeInteger(msex.ullAvailPhys, szAvailPhys, 40, TRUE); 60 ConvertULargeInteger(msex.ullTotalPageFile, szTotalPageFile, 40, TRUE); 61 ConvertULargeInteger(msex.ullAvailPageFile, szAvailPageFile, 40, TRUE); 62 ConvertULargeInteger(msex.ullTotalVirtual, szTotalVirtual, 40, TRUE); 63 ConvertULargeInteger(msex.ullAvailVirtual, szAvailVirtual, 40, TRUE); 64 65 ConOutResPrintf(STRING_MEMORY_HELP2, 66 szMemoryLoad, szTotalPhys, szAvailPhys, szTotalPageFile, 67 szAvailPageFile, szTotalVirtual, szAvailVirtual); 68 69 return 0; 70 } 71 72 #endif /* INCLUDE_CMD_MEMORY */ 73 74 /* EOF */ 75