# VBForums CodeBank > CodeBank - Other >  [DELPHI] - Get CPU Usage

## Madboy

```
uses, Registry

procedure TForm1.Button1Click(Sender: TObject); 
var 
  Dummy : array[0..1024] of byte; 
begin 
  // Stats started by Button1 hit 
  Reg:=TRegistry.Create; 
  Reg.RootKey:=HKEY_DYN_DATA; 
  Reg.OpenKey('PerfStats\StartStat',false);      // Open this key first to start collecting performance data 
  Reg.ReadBinaryData('KERNEL\CPUUsage',Dummy,Sizeof(Dummy)); 
  Reg.CloseKey; 
  started:=true; 
end; 

procedure TForm1.Timer1Timer(Sender: TObject); 
var 
  CPUU : integer; 
begin 
  if started then 
  begin 
    Reg.OpenKey('PerfStats\StatData',false); 
    Reg.ReadBinaryData('KERNEL\CPUUsage',CPUU,SizeOf(Integer)); 
    Reg.CloseKey; 
    Label1.Caption:=IntToStr(CPUU)+'%'; 
  end; 
end; 

procedure TForm1.Button2Click(Sender: TObject); 
var 
  Dummy : array[0..1024] of byte; 
begin 
  Reg.OpenKey('PerfStats\StopStat',false); 
  Reg.ReadBinaryData('KERNEL\CPUUsage',Dummy,SizeOf(Dummy)); 
  Reg.Free; 
  Started:=false; 
end;
```

----------

