首页 > 其他 > 详细

获取cpu使用率

时间:2021-03-04 14:59:08      阅读:23      评论:0      收藏:0      [点我收藏+]

获取cpu使用率

支持跨操作系统获取。

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.

  

 

获取cpu使用率

原文:https://www.cnblogs.com/hnxxcxg/p/14479808.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!