Решил поделиться небольшим примером индикатора загрузки процессоров на Delphi. За основу взят компонент adCpuUsage. Думаю, что это дополнение в ваши приложения не будет лишним.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,AdCpuUsage, ExtCtrls, ComCtrls, WinSock, Gauges, StdCtrls;type
TForm1 = class(TForm)
StatusBar: TStatusBar;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
endvar
Form1 : TForm1;
CPU : Integer;implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
GInitData : TWSAData;
i : Integer;
Gauge : TGauge;
begin
for i:=1 to GetCPUCount-1 do
begin
try
Gauge:=TGauge.Create(Form1);
Gauge.Name:=Format('Gauge%d',[i]);
with TGauge(FindComponent(Format('Gauge%d',[i]))) do
begin
Parent:=StatusBar;
Top:=2;
Width:=100;
Height:=18;
Left:=((i-1)*Width);
MinValue:=0;
MaxValue:=100;
ForeColor:=StatusBar.Color;
end;
except
end;
end;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
n:Integer;
begin
CollectCPUData;
for n:=1 to GetCPUCount-1 do
begin
TGauge(FindComponent('Gauge'+IntToStr(n))).Progress:=StrToInt(Format('%0.0f%',[GetCPUUsage(n)*100]));
CPU:=StrToInt(Format('%0.0f%',[GetCPUUsage(n)*100]));
end;
end;end.
cpu.rar (174,8 КиБ, 3 328 hits)