...get the CPU name/ speed?

Author: Eduardo Teixeira

Category: System

// this code will get the cpu identifier from the windows registry

uses
  
Registry;

function CPUname: string;
var
  
Reg: TRegistry;
begin
  
CPUname := '';
  Reg := TRegistry.Create;
  try
    
Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Hardware\Description\System\CentralProcessor\0', False) then
      
CPUname := Reg.ReadString('Identifier');
  finally
    
Reg.Free;
  end;
end;

// this code will get the cpu speed from the windows registry

uses
  
Registry;

function GetCpuSpeed: string;
var
  
Reg: TRegistry;
begin
  
Reg := TRegistry.Create;
  try
    
Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('Hardware\Description\System\CentralProcessor\0', False) then
    begin
      
Result := IntToStr(Reg.ReadInteger('~MHz')) + ' MHz';
      Reg.CloseKey;
    end;
  finally
    
Reg.Free;
  end;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base