{
Sample source code for reading CORETEMP shared memory written in Borland Delphi
Copyright (C) 2008 Tiu Hathor
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see [url]http://www.gnu.org/licenses/[/url]
Contact: [email]tiu-hathor@web.de[/email]
[url]http://www.alcpu.com/CoreTemp/developers.html[/url]
[email]Arthur_Liberman@hotmail.com[/email]
}
unit CTread;
interface
uses
Windows,
StdCtrls,
Controls,
Classes,
Forms,
SysUtils,
ExtCtrls;
//Core Temp shared memory Translation C++ > DELPHI : (c) 2008 Tiu Hathor
Type
TCTInfo =
record
uiLoad :
array [0..255]
of Cardinal;
//256 = 1024 bytes
uiTjMax :
array [0..127]
of Cardinal;
//128 = 512 bytes
uiCoreCnt :Cardinal;
// 4 bytes
uiCPUCnt :Cardinal;
// 4 bytes
fTemp :
array [0..255]
of single;
//256 * 4 bytes = 1024 bytes
fVID : single;
//real 4 bytes
fCPUSpeed : single;
//real 4 bytes
fFSBSpeed : single;
//real 4 bytes
fMultiplier : single;
//real 4 bytes
sCPUName :
array [0..99]
of Char;
//String[100]; = 100 bytes
ucFahrenheit : Boolean;
// 1 byte
ucDeltaToTjMax: Boolean;
// 1 byte
end;
// 2686 bytes
PCTInfo = ^TCTInfo;
TForm1 =
class(TForm)
Timer1: TTimer;
Memo1: TMemo;
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
CTInfo : PCTInfo;
hMapFile : Integer;
implementation
{$R *.DFM}
function ReadCTInfo : Boolean;
begin
hMapFile := OpenFileMapping(FILE_MAP_READ, False, '
CoreTempMappingObject');
if hMapFile > 0
then
begin
CTInfo := MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
Result := True;
end else result := false;
CloseHandle(hMapFile);
end;
//-----------------------------------------------------------------------------
procedure TForm1.FormShow(Sender: TObject);
begin
Memo1.Clear;
if ReadCTInfo = True
then
BEGIN
Memo1.Lines.Add('
CTInfo: ok');
Timer1.Enabled:= true;
END else
Memo1.Lines.Add('
CTInfo: ERROR. CORETEMP is NOT running!');
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
UnmapViewOfFile(CTInfo);
CloseHandle(hMapFile);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Memo1.Clear;
Memo1.Lines.Add('
CTInfo: CpuName: '+ CTInfo.sCPUName);
Memo1.Lines.Add('
');
Memo1.Lines.Add('
CTInfo: Core0: '+ FloatToStr(CTInfo.fTemp[0])+ '
°C');
Memo1.Lines.Add('
CTInfo: Core1: '+ FloatToStr(CTInfo.fTemp[1])+ '
°C');
Memo1.Lines.Add('
CTInfo: Core2: '+ FloatToStr(CTInfo.fTemp[2])+ '
°C');
Memo1.Lines.Add('
CTInfo: Core3: '+ FloatToStr(CTInfo.fTemp[3])+ '
°C');
Memo1.Lines.Add('
');
Memo1.Lines.Add('
CTInfo: Load-Core0: '+ IntToStr(CTInfo.uiLoad[0])+ '
%');
Memo1.Lines.Add('
CTInfo: Load-Core1: '+ IntToStr(CTInfo.uiLoad[1])+ '
%');
Memo1.Lines.Add('
CTInfo: Load-Core2: '+ IntToStr(CTInfo.uiLoad[2])+ '
%');
Memo1.Lines.Add('
CTInfo: Load-Core3: '+ IntToStr(CTInfo.uiLoad[3])+ '
%');
Memo1.Lines.Add('
');
Memo1.Lines.Add('
CTInfo: TjMax: '+ IntToStr(CTInfo.uiTjMax[0])+ '
°C');
Memo1.Lines.Add('
CTInfo: CpuCoreCount: '+ IntToStr(CTInfo.uiCoreCnt));
Memo1.Lines.Add('
CTInfo: CpuCount: '+ IntToStr(CTInfo.uiCPUCnt));
Memo1.Lines.Add('
CTInfo: CpuVID: '+ Format('
%.5g', [CTInfo.fVID]) + '
Volt');
Memo1.Lines.Add('
CTInfo: CpuSpeed: '+ Format('
%.6g', [CTInfo.fCPUSpeed]) + '
MHz');
Memo1.Lines.Add('
CTInfo: CpuFSBSpeed: '+ Format('
%.3g', [CTInfo.fFSBSpeed]) + '
MHz');
Memo1.Lines.Add('
CTInfo: CpuMultiplier: '+ FloatToStr(CTInfo.fMultiplier));
Memo1.Lines.Add('
CTInfo: Fahrenheit: '+ BoolToStr(CTInfo.ucFahrenheit));
Memo1.Lines.Add('
CTInfo: DeltaToTjMax: '+ BoolToStr(CTInfo.ucDeltaToTjMax));
end;
end.