Get the Percentage of Total CPU Usage

后端 未结 5 912
萌比男神i
萌比男神i 2021-01-03 05:00

I am trying to get the % of total CPU usage to a label1.Caption

I\'ve searched and found these:

  • didn\'t work - http://www.vbforums.com

5条回答
  •  甜味超标
    2021-01-03 05:11

    I found t h i s

    does the job

    uses adCpuUsage;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    u:string;
    begin
      collectcpudata;
       for i:=0 to GetCPUCount-1 do
    
     u:=FloatToStr(Round(getcpuusage(i)*100));   //Round to approximate 1.0003 to 1
    
    label1.Caption:=u
    end;
    
    end.
    

    worked for me

提交回复
热议问题