cpu and memory load

Hi,

Does anyone know how to get the current cpu load (in percentage). And the memory load (Ram and swap, if possible seperate).

Thanks
Marc
hellfire052497Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
if this is for win9*
try this for cpu usage(it dont work for me though)

procedure UpdateTimer(Sender: TObject);
var
 RegIni  : TRegIniFile;
 I       : Integer;
begin
 RegIni := TRegIniFile.Create('');
 with RegIni do
  begin
   RootKey := HKEY_DYN_DATA;
   LazyWrite := True;
   OpenKey('\Perfstats\StatData',False);

   ReadBinaryData('KERNEL\CPUUsage', I, SizeOf(I));
   Free;
  end;
  OvcMeter1.Percent := I;
end;


i can give some other stuff (imcomplete)for nt to get he cpu usage by each process.



for the memory stuff you can use this:

unit GlobalMemoryStatusU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TGlobalMemoryStatusForm = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    ButtonGlobalMemoryStatus: TButton;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    procedure ButtonGlobalMemoryStatusClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  GlobalMemoryStatusForm: TGlobalMemoryStatusForm;

implementation

{$R *.DFM}

procedure TGlobalMemoryStatusForm.ButtonGlobalMemoryStatusClick(
  Sender: TObject);
var
  GlobalMemoryInfo : TMemoryStatus;  // holds the global memory status information
begin
  {set the size of the structure before the call.}
  GlobalMemoryInfo.dwLength := SizeOf(GlobalMemoryInfo);

  {retrieve the global memory status...}
  GlobalMemoryStatus(GlobalMemoryInfo);

  {and display the information}
  Label1.caption := 'Results of GlobalMemoryStatus:';
  Label2.caption := 'Record structure size: '+IntToStr(
                     GlobalMemoryInfo.dwLength)+' bytes';
  Label3.caption := 'Current memory load: '+IntToStr(
                     GlobalMemoryInfo.dwMemoryLoad)+'%';
  Label4.caption := 'Total physical memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwTotalPhys/1])+' bytes';
  Label5.caption := 'Total available physical memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwAvailPhys/1])+' bytes';
  Label6.caption := 'Total paging file size: '+Format('%.0n',[
                     GlobalMemoryInfo.dwTotalPageFile/1])+' bytes';
  Label7.Caption := 'Total available paging file memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwAvailPageFile/1])+' bytes';
  Label8.caption := 'Total virtual memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwTotalVirtual/1])+' bytes';
  Label9.caption := 'Total available virtual memory: '+Format('%.0n',[
                     GlobalMemoryInfo.dwAvailVirtual/1])+' bytes';
end;

end.
0
hellfire052497Author Commented:
Hi,

sure give the NT stuff too, i'm switching to it next week.

Thanks
Marc
0
intheCommented:
see here for some (kind of relevent)info:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10243139 

but use the components from this link:
http://aldyn.chat.ru/
they work only on nt.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

bryan7Commented:
listenning
0
rwilson032697Commented:
Eavesdropping
0
hellfire052497Author Commented:
Hi,

great, it all works. If you like to lock the question so I can give you the points

Marc
0
intheCommented:
thanks ;-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.