Originally from: http://my.oschina.net/pc100/blog/380020
In general, we use GlobalMemoryStatus to get the physical memory size, but the API returns a value of 2GB when the physical memory size exceeds 2G. Therefore, there is no way to get the actual physical memory size, so this needs to be improved.
Define the TMEMORYSTATUSEX structure:
Type tmemorystatusex = packed record dwlength:dword; Dwmemoryload:dword; Ulltotalphys:int64; Ullavailphys:int64; Ulltotalpagefile:int64; Ullavailpagefile:int64; Ulltotalvirtual:int64; Ullavailvirtual:int64; Ullavailextendedvirtual:int64; End Function GlobalMemoryStatusEx (var lpbuffer:tmemorystatusex): BOOL; stdcall; External kernel32; Memorystatusex.dwlength: = SizeOf (Memorystatusex); GlobalMemoryStatusEx (Memorystatusex); MEMO2.LINES.ADD (formatfloat (' #,### ', Ulltotalphys)); If the real memory exceeds 4G, the real memory limit is shown to 3.5G. Of course, if the machine is 64-bit, it will be displayed.
Description: The above environment for 32-bit operating system if your operating system is 64-bit will not have the above problems
How Delphi obtains physical memory size greater than 2G [Delphi]