1. Technology

Programmatically Get Memory Status

By

To retrieve the current memory status, use the GlobalMemoryStatus() function. The TMemoryStatus contains several fields indicating the status of the memory:

.dwMemoryLoad: Total memory used in percentage (%)
.dwTotalPhys: Total physical memory in bytes.
.dwAvailPhys: Physical memory left in bytes.
.dwTotalPageFile: Total page file in bytes.
.dwAvailPageFile:Page file left in bytes.
.dwTotalVirtual: Total virtual memory in bytes.
.dwAvailVirtual: Virtual memory left in bytes.

Before presenting the memory values, convert them into giga, mega or kilobytes.

 var
    Status : TMemoryStatus;
 begin
    Status.dwLength := sizeof(TMemoryStatus) ;
    GlobalMemoryStatus(Status) ;
 
    ShowMessage(Format('Virtual: %d',[Status.dwTotalVirtual])) ;
 end;
 
Delphi tips navigator:
» Exit From Windows
« Programmatically Disable Mouse and Keyboard
Delphi tips navigator:
» Exit From Windows
« Disable mouse and keyboard

©2014 About.com. All rights reserved.