- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
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.
演示图