@Bill
You need to use GlobalMemoryStatusEx. This is not ideal, but it is better than GlobalMemoryStatus. How? With GlobalMemoryStatus, on a 4 GB computer with Win32, a 32-bit application only shows 2 GB. Using GlobalMemoryStatusEx, 3 GB will be installed in the same application. A little closer to the truth!
This code works the same as in Delphi XE (and above):
uses Windows; function GetSystemMem: string; { Returns installed RAM (as viewed by your OS) in GB, with 2 decimals } VAR MS_Ex : MemoryStatusEx; begin FillChar (MS_Ex, SizeOf(MemoryStatusEx), #0); MS_Ex.dwLength := SizeOf(MemoryStatusEx); GlobalMemoryStatusEx (MS_Ex); Result:= Real2Str(MS_Ex.ullTotalPhys / GB, 2)+ ' GB'; end;
Please note that using some API functions will probably never give you the TOTAL amount if this amount exceeds 3 GB and the OS Win 32. Why? Because Windows32 itself cannot "see" all the memory! You need to access the BIOS directly and read the hardware values ββthere. HOWEVER, in some cases this may not be necessary for this: why bother to show that your computer has 4 GB of RAM, if only 3 are available? What I did IN MY CASE, I changed the message:
Installed RAM: 3 GB (or more)
from
Available RAM: 3 GB
Again, I don't know if this is appropriate in your case.
source share