本文整理自网络,侵删。
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);beginTThread.GetSystemTimes(Times); end;
procedure TForm1.Timer1Timer(Sender: TObject);var Usage: Integer;begin Usage := TThread.GetCPUUsage(Times); form1.Caption := IntToStr(Usage) + '%';end;
end.
演示图
相关阅读 >>
Delphi unigui中如何监听session的开始与结束
Delphi cannot find implementation of method formcreate 解决办法
Delphi cb_addstring 与lb_addstring的区别?
更多相关阅读请进入《Delphi》频道 >>