(************************************************************************
*    This File is Part of the AHM Triton Tools                          *
*    for Borland Delphi and C++ Builder.                                *
*************************************************************************
* Copyright © 1995-1999 Alexander H. Mehlhorn (AHM) and Tritontools.com *
* All Rights reserved.                                                  *
*                                                                       *
*    For more Information contact us at                                 *
*    E-Mail : support@tritontools.com                                   *
*    URL : http://www.tritontools.com                                   *
*                                                                       *
*    AHM is copyright by Alexander H. Mehlhorn                          *
*    All Parts of this Collection were developed,                       *
*    designed and implemented by AHM                                    *
*                                                                       *
*    Under no Circumstances may you distribute this file                *
*    in this or any other format. This File is supplied                 *
*    as Evaluation of Source only. No Delphi Components may be developed*
*    using extracts or subsets of this code without expressed permission*
*    by AHM.                                                            *
*                                                                       *
*************************************************************************)
unit AHMTResourceDetails;

interface

uses Windows, Classes, AHMSystemClass;

type
  TAHMResourceDetails = class(TAHMSystemsComponent)
  private
    { Private declarations }
    FMemoryLoad : DWord;
    FTotalPhysical : DWord;
    FAvailPhysical : DWord;
    FAvailPageFile : DWord;
    FTotalPageFile : DWord;
    FTotalVirtual : DWord;
    FAvailVirtual : DWord;
    FOnUpdate: TNotifyevent;
    function GetAvailPhysical: DWord;
    function GetAvailVirtual: DWord;
    function GetMemoryLoad: DWord;
    function GetTotalPageFile: DWord;
    function GetTotalPhysical: DWord;
    function GetTotalVirtual: DWord;
    procedure SetDWord(const Value: DWord);
    function GetAvailPageFile: DWord;
  protected
    { Protected declarations }

  public
    Constructor Create(AOwner : TComponent); override;
    Procedure Loaded; override;
    { Public declarations }
    procedure UpdateResources;
  published
    { Published declarations }
    property MemoryLoad : DWord read GetMemoryLoad write SetDWord stored False;
    property TotalPhysical : DWord read GetTotalPhysical write SetDWord stored False;
    property AvailPhysical : DWord read GetAvailPhysical write SetDWord stored False;
    property AvailPageFile : DWord read GetAvailPageFile write SetDWord stored False;
    property TotalPageFile : DWord read GetTotalPageFile write SetDWord stored False;
    property TotalVirtual : DWord read GetTotalVirtual write SetDWord stored False;
    property AvailVirtual : DWord read GetAvailVirtual write SetDWord stored False;
    property OnUpdate : TNotifyevent read FOnUpdate write FOnUpdate;
  end;

implementation

{ TAHMResourceDetails }

procedure TAHMResourceDetails.UpdateResources;
var MemoryStatus : TMemoryStatus;
begin
  FillChar(MemoryStatus,SizeOf(MemoryStatus),0);
  MemoryStatus.dwLength := SizeOf(MemoryStatus);
  GlobalMemoryStatus(MemoryStatus);
  with MemoryStatus do
  begin
    FMemoryLoad := dwMemoryLoad;
    FTotalPhysical := dwTotalPhys;
    FAvailPhysical := dwAvailPhys;
    FTotalPageFile := dwTotalPageFile;
    FAvailPageFile := dwAvailPageFile;
    FTotalVirtual := dwTotalVirtual;
    FAvailVirtual := dwAvailVirtual;
  end;
  if assigned(FOnUpdate) then FOnUpdate(Self);
end;


function TAHMResourceDetails.GetAvailPhysical: DWord;
begin
  result:=FAvailPhysical;
end;

function TAHMResourceDetails.GetAvailVirtual: DWord;
begin
  result:=FAvailVirtual;
end;

function TAHMResourceDetails.GetMemoryLoad: DWord;
begin
  result:=FMemoryLoad;
end;

function TAHMResourceDetails.GetTotalPageFile: DWord;
begin
  result:=FTotalPageFile;
end;

function TAHMResourceDetails.GetTotalPhysical: DWord;
begin
  result:=FTotalPhysical;
end;

function TAHMResourceDetails.GetTotalVirtual: DWord;
begin
  result:=FTotalVirtual;
end;

procedure TAHMResourceDetails.SetDWord(const Value: DWord);
begin
  {for designtime viewing only}
end;

function TAHMResourceDetails.GetAvailPageFile: DWord;
begin
  result:=FAvailPageFile;
end;

constructor TAHMResourceDetails.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  UpdateResources;
end;

procedure TAHMResourceDetails.Loaded;
begin
  inherited Loaded;
  UpdateResources;
end;

end.
