1. Technology

Programmatically Get Memory Status


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.

    Status : TMemoryStatus;
    Status.dwLength := sizeof(TMemoryStatus) ;
    GlobalMemoryStatus(Status) ;
    ShowMessage(Format('Virtual: %d',[Status.dwTotalVirtual])) ;
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.