Delphi 获取CPU Monitor使用率


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils,System.StrUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
    Times: TThread.TSystemTimes;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.FormCreate(Sender: TObject);
begin
TThread.GetSystemTimes(Times);
  end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  Usage: Integer;
begin
  Usage := TThread.GetCPUUsage(Times);
  form1.Caption := IntToStr(Usage) + '%';
end;

end.

演示图


相关阅读 >>

Delphi 自带大小写转换

Delphi获得webbrowser中的html文本

Delphi firedac sqlite不能插入"&"符号

Delphi application.restore不起作用了,该如何处理

Delphi 防止程序重复执行的单元

常用的几个网络函数和系统函数

Delphi 使用webbrowser控件获取含框架的网页的完整html代码

Delphi shellexecute最简单的结束进程代码

Delphi中调用必应搜索(bing)的api函数

Delphi 截取某个字符之前的字段

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...