////////////////////////////////////////////////////////////////////////////////
//
// Den Arbeitsspeicher auslesen, wenn dieser mehr als 2 GB beträgt
//
type
SIZE_T = Cardinal;
{$EXTERNALSYM SIZE_T}
DWORDLONG = Int64;
// ULONGLONG
{$EXTERNALSYM DWORDLONG}
type
PMemoryStatus = ^TMemoryStatus;
LPMEMORYSTATUS = PMemoryStatus;
{$EXTERNALSYM LPMEMORYSTATUS}
_MEMORYSTATUS =
packed record
dwLength : DWORD;
dwMemoryLoad : DWORD;
dwTotalPhys : SIZE_T;
dwAvailPhys : SIZE_T;
dwTotalPageFile: SIZE_T;
dwAvailPageFile: SIZE_T;
dwTotalVirtual : SIZE_T;
dwAvailVirtual : SIZE_T;
end;
{$EXTERNALSYM _MEMORYSTATUS}
TMemoryStatus = _MEMORYSTATUS;
MEMORYSTATUS = _MEMORYSTATUS;
{$EXTERNALSYM MEMORYSTATUS}
type
PMemoryStatusEx = ^TMemoryStatusEx;
LPMEMORYSTATUSEX = PMemoryStatusEx;
{$EXTERNALSYM LPMEMORYSTATUSEX}
_MEMORYSTATUSEX =
packed record
dwLength : DWORD;
dwMemoryLoad : DWORD;
ullTotalPhys : DWORDLONG;
ullAvailPhys : DWORDLONG;
ullTotalPageFile: DWORDLONG;
ullAvailPageFile: DWORDLONG;
ullTotalVirtual : DWORDLONG;
ullAvailVirtual : DWORDLONG;
end;
{$EXTERNALSYM _MEMORYSTATUSEX}
TMemoryStatusEx = _MEMORYSTATUSEX;
MEMORYSTATUSEX = _MEMORYSTATUSEX;
{$EXTERNALSYM MEMORYSTATUSEX}
//---
procedure GlobalMemoryStatus(
var lpBuffer: TMemoryStatus);
stdcall;
external kernel32;
{$EXTERNALSYM GlobalMemoryStatus}
function GlobalMemoryStatusEx(
var lpBuffer: TMemoryStatusEx): BOOL;
stdcall;
type
TFNGlobalMemoryStatusEx =
function(
var msx: TMemoryStatusEx): BOOL;
stdcall;
var
FNGlobalMemoryStatusEx: TFNGlobalMemoryStatusEx;
begin
FNGlobalMemoryStatusEx := TFNGlobalMemoryStatusEx(
GetProcAddress(GetModuleHandle(kernel32), '
GlobalMemoryStatusEx'));
if not Assigned(FNGlobalMemoryStatusEx)
then
begin
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
Result := False;
end
else
Result := FNGlobalMemoryStatusEx(lpBuffer);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Status: TMemoryStatusEx;
begin
Label1.Caption := '
Total RAM: ' + IntToStr(Status.ullTotalPhys);
Label2.Caption := '
Verfügbar RAM: ' + IntToStr(Status.ullAvailPhys);
Label3.Caption := '
Total Pagefile: ' + IntToStr(Status.ullTotalPageFile);
Label4.Caption := '
Verfügbar Pagefile: ' + IntToStr(Status.ullAvailPageFile);
Label5.Caption := '
Total Virtuell: ' + IntToStr(Status.ullTotalVirtual);
Label6.Caption := '
Verfügbar Virtuell: ' + IntToStr(Status.ullAvailVirtual);
end;