Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > Oracle Database, SQL, Application, Programming


GlobalMemoryStatus() to the rescue


Reply
Views: 1463  
Thread Tools Rate Thread
  #1  
Old 08-11-2010, 02:37 PM
bholas bholas is offline
Award Winner
 
Join Date: Apr 2010
Posts: 4,977
Default GlobalMemoryStatus() to the rescue

"GetFreeSystemResources()" Win16 API function is no longer supported in Win32 API, but you can use "GlobalMemoryStatus()" to get even more memory related information:
var
ms : TMemoryStatus;
begin
ms.dwLength := SizeOf( ms );
GlobalMemoryStatus( ms );
with ms do
begin
//
// now you can use any of
// the following parameters
//

// percent of memory in use
{dwMemoryLoad}

// bytes of physical memory
{dwTotalPhys}

// free physical memory bytes
{dwAvailPhys}

// bytes of paging file
{dwTotalPageFile}

// free bytes of paging file
{dwAvailPageFile}

// user bytes of address space
{dwTotalVirtual}

// free user bytes
{dwAvailVirtual}
end;
end;
Listing #1 : Delphi code. Download memstat (0.38 KB).


For example:
function GetMemoryTotalPhys : DWord;
var
ms : TMemoryStatus;
begin
ms.dwLength := SizeOf( ms );
GlobalMemoryStatus( ms );
Result := ms.dwTotalPhys;
end;

procedure TForm1.****on1Click(Sender: TObject);
begin
MessageDlg(
'total physical memory: ' +
IntToStr( GetMemoryTotalPhys )
, mtInformation, [mbOk], 0 );
end;

Reply With Quote
Reply

Tags
pc tips

New topics in Oracle Database, SQL, Application, Programming





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)