获取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.
原文:https://www.cnblogs.com/hnxxcxg/p/14479808.html