unit Unit2;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.StdCtrls;
type
TForm2 =
class(TForm)
Memo1: TMemo;
Timer1: TTimer;
Button1: TButton;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
// http://www.alcpu.com/CoreTemp/developers.html
type
CORE_TEMP_SHARED_DATA_EX =
packed record
uiLoad:
packed array [0 .. 255]
of Cardinal;
uiTjMax:
packed array [0 .. 127]
of Cardinal;
uiCoreCnt: Cardinal;
uiCPUCnt: Cardinal;
fTemp:
packed array [0 .. 255]
of Single;
fVID: Single;
fCPUSpeed: Single;
fFSBSpeed: Single;
fMultipier: Single;
sCPUName:
packed array [0 .. 99]
of AnsiChar;
ucFahrenheit: ByteBool;
ucDeltaToTjMax: ByteBool;
//new struct
ucTdpSupported: ByteBool;
ucPowerSupported: ByteBool;
uiStructVersion: Cardinal;
uiTdp:
packed array [0 .. 127]
of Cardinal;
fPower:
packed array [0 .. 127]
of Single;
fMultipliers:
packed array [0 .. 255]
of Single;
end;
const
CoreTempSharedAreaEx = '
CoreTempMappingObjectEx';
function fnGetCoreTempInfoEx(
out DataEx: CORE_TEMP_SHARED_DATA_EX): Boolean;
implementation
{$R *.dfm}
function fnGetCoreTempInfoEx(
out DataEx: CORE_TEMP_SHARED_DATA_EX): Boolean;
var
HCoreTempSharedAreaEx: Cardinal;
PCoreTempSharedAreaEx: Pointer;
begin
Result := False;
HCoreTempSharedAreaEx := OpenFileMapping(FILE_MAP_READ, True,
CoreTempSharedAreaEx);
if HCoreTempSharedAreaEx <> 0
then
try
PCoreTempSharedAreaEx := MapViewOfFile(HCoreTempSharedAreaEx, FILE_MAP_READ,
0, 0, SizeOf(DataEx));
if Assigned(PCoreTempSharedAreaEx)
then
try
FillChar(DataEx, SizeOf(DataEx), 0);
Move(PCoreTempSharedAreaEx^, DataEx, SizeOf(DataEx));
Result := True;
finally
UnmapViewOfFile(PCoreTempSharedAreaEx);
end;
finally
CloseHandle(HCoreTempSharedAreaEx);
end;
end;
procedure MM(s:
string);
begin Form2.Memo1.Lines.Add(s);
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm2.FormShow(Sender: TObject);
var
DataEx: CORE_TEMP_SHARED_DATA_EX;
CPU, Core,
Index: Cardinal;
Degree: Char;
Temp : Single;
fCPUSpeedR : Extended;
YY1, YY2 : INTEGER;
begin
Memo1.Clear; MM('
');
if fnGetCoreTempInfoEx(DataEx)
then
begin
MM('
Processor: ' + DataEx.sCPUName);
MM('
CPUs : ' + IntToStr(DataEx.uiCPUCnt));
MM('
TDP: ' + IntToStr(DataEx.uiTDP[0]) + '
Watt');
MM('
Cores: ' + IntToStr(DataEx.uiCoreCnt));
fCPUSpeedR:= ROUND(DataEx.fCPUSpeed / 100)*100;
MM('
CPU: ' + FloatToStrF(fCPUSpeedR, ffFixed, 7, 0) + '
MHz');
MM('
VID: ' + FloatToStrF(DataEx.fVID, ffFixed, 7, 2) + '
Volt');
MM('
Power: ' + FloatToStrF(DataEx.fPower[0], ffFixed, 7, 1) +'
Watt');
CPU := 0;
MM('
');
for Core := 0
to DataEx.uiCoreCnt - 1
do
begin
Index := (CPU * DataEx.uiCoreCnt) + Core;
Temp := DataEx.fTemp[
Index];
MM('
CORE '+ IntToStr(Core)+'
Temp: ' + FloatToStrF(Temp, ffFixed, 7, 0)+ '
°C');
end;
MM('
');
for Core := 0
to DataEx.uiCoreCnt - 1
do
begin
Index := (CPU * DataEx.uiCoreCnt) + Core;
Temp := DataEx.fTemp[
Index];
MM('
CORE '+ IntToStr(Core)+'
Load: ' + IntToStr(DataEx.uiLoad[
Index]) + '
%');
end;
end;
Button1.SetFocus;
end;
end.