{
Author : Michael Puff - [url]http://www.michael-puff.de[/url]
Date : 2006-02-15
License : PUBLIC DOMAIN
}
type
PROCESSOR_POWER_INFORMATION =
packed record
Number: Cardinal;
MaxMhz: Cardinal;
CurrentMhz: Cardinal;
MhzLimit: Cardinal;
MaxIdleState: Cardinal;
CurrentIdleState: Cardinal;
end;
PPROCESSOR_POWER_INFORMATION = ^PROCESSOR_POWER_INFORMATION;
TCPUFrequency =
packed record
CurrentMhz: Cardinal;
MaxMhz: Cardinal;
end;
function CallNtPowerInformation(InformationLevel: DWORD; InPutBuffer: Pointer; InputBufferSize: ULONG; OutPutBuffer:
Pointer; OutPutBufferSize: ULONG): DWORD;
stdcall;
external '
PowrProf.dll';
function GetCPUFrequency(
var CPUFrequency: TCPUFrequency): DWORD;
var
ppi: PROCESSOR_POWER_INFORMATION;
err: DWORD;
begin
ZeroMemory(@ppi, sizeof(PROCESSOR_POWER_INFORMATION));
err := CallNTPowerInformation(11,
nil, 0, @ppi, sizeof(PROCESSOR_POWER_INFORMATION));
if err = 0
then
begin
CPUFrequency.CurrentMhz := ppi.CurrentMhz;
CPUFrequency.MaxMhz := ppi.MaxMhz;
end;
result := err;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
CPUFrequency: TCPUFrequency;
err: DWORD;
s:
String;
begin
ZeroMemory(@CPUFrequency, sizeof(TCPUFrequency));
err := GetCPUFrequency(CPUFrequency);
if err = 0
then
begin
s := '
Current frequency: '+IntToStr(CPUFrequency.CurrentMhz)+'
MHz'+#13#10;
s := s + '
Max frequency: '+IntToStr(CPUFrequency.MaxMhz)+'
MHz';
ShowMessage(s);
end
else
ShowMessage(SysErrorMessage(err));
end;