获取CPU使用总量的百分比 [英] Get the Percentage of Total CPU Usage
本文介绍了获取CPU使用总量的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将总CPU占用率的百分比设为 label1.Caption
搜索并找到这些:
-
没有工作 -
这是我正在工作的:
我相信有一种简单的方式,比如当我们获得RAM使用时。 >
GlobalMemoryStatus(RamStats);
Label1.Caption:= Format('RAM:%d %%',[RamStats.dwMemoryLoad]);
解决方案
我发现
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/showthread.php?345723-DELPHI-Get-CPU-Usage
not what I need - http://delphi.cjcsoft.net/viewthread.php?tid=42837
- also found bunch of solutions regarding calculating the Usage per process but that is not what i am looking for , i just want the total CPU usage like this widget :
this is what i am working on :
I believe there is a simple way like when we get RAM usage.
GlobalMemoryStatus(RamStats);
Label1.Caption := Format('RAM: %d %%', [RamStats.dwMemoryLoad]);
解决方案
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
这篇关于获取CPU使用总量的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文