Is there a a way to obtain Total and Available memory when more than 4 GB of memory is installed with Delphi 2010 on Windows 7?
This code does not return more than 3.99 GB:
var
Memory: TMemoryStatus;
Memory.dwLength := SizeOf( Memory );
GlobalMemoryStatus( Memory );
dwTotalPhys1.Caption := 'Total memory: ' + IntToStr( Memory.dwTotalPhys ) + ' Bytes ' + '(' + FormatByteSize
( Memory.dwTotalPhys ) + ')';
dwAvailPhys1.Caption := 'Available memory: ' + IntToStr( Memory.dwAvailPhys ) + ' Bytes ' + FormatByteSize
( Memory.dwAvailPhys ) + ')';
You need to use the GlobalMemoryStatusEx.
GlobalMemoryStatusis limited to 4gbI don’t know if it’s already defined in Delphi with its structure
TMemoryStatusExor not (it would be based on the MEMORYSTATUSEX of the Windows API.)The fields you’ll have to look are
ullTotalPhysandullAvailPhys. They are 64 bit unsigned integers.I was forgetting, it’s supported only by Windows >= 2000, but this shouldn’t be a problem anymore.