Get system info (free memory, etc)

Put a TMemo (Memo1) and a TButton (Button1) in your form. Put this code into OnClick of Button1:

procedure TForm1.Button1Click(Sender: TObject) ;
var MemoryStatus: TMemoryStatus;
begin
  Memo1.Lines.Clear;
  MemoryStatus.dwLength := SizeOf(MemoryStatus) ;
  GlobalMemoryStatus(MemoryStatus) ;
  with MemoryStatus do begin
   Memo1.Lines.Add(IntToStr(dwLength) +
     ‘ Size of ”MemoryStatus” record’) ;
   Memo1.Lines.Add(IntToStr(dwMemoryLoad) +
     ‘% memory in use’) ;
   Memo1.Lines.Add(IntToStr(dwTotalPhys) +
     ‘ Total Physical Memory in bytes’) ;
   Memo1.Lines.Add(IntToStr(dwAvailPhys) +
     ‘ Available Physical Memory in bytes’) ;
   Memo1.Lines.Add(IntToStr(dwTotalPageFile) +
     ‘ Total Bytes of Paging File’) ;
   Memo1.Lines.Add(IntToStr(dwAvailPageFile) +
     ‘ Available bytes in paging file’) ;
   Memo1.Lines.Add(IntToStr(dwTotalVirtual) +
     ‘ User Bytes of Address space’) ;
   Memo1.Lines.Add(IntToStr(dwAvailVirtual) +
     ‘ Available User bytes of address space’) ;
  end;
end;

Leave a Reply

Your email address will not be published. Required fields are marked *