Mega Code Archive

 
Categories / Delphi / Hardware
 

Amount of installed ram

Question: How do I get the amount of RAM installed on a system and display it in megabytes? Answer: You can determine this with the Win32 function GlobalMemoryStatus(). See the little function below. program dummy; uses Dialogs, Windows, SysUtils; function DisplayRam : String; var Info: TMemoryStatus; begin Info.dwLength := sizeof(TMemoryStatus); GlobalMemoryStatus(Info); Result := Format('%d MB RAM', [(Info.dwTotalPhys SHR 20) + 1]) end; begin ShowMessage(DisplayRam) end.