Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Software-Projekte der Mitglieder (https://www.delphipraxis.net/26-software-projekte-der-mitglieder/)
-   -   CORETEMP mit Shared Memory (https://www.delphipraxis.net/114483-coretemp-mit-shared-memory.html)

hathor 26. Mai 2008 10:49


CORETEMP mit Shared Memory
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hi,
seit der neuen CORETEMP 0.99-Version gibt es Shared Memory.

CORETEMP gibt es hier:
http://www.alcpu.com/CoreTemp/

Den DELPHI-Sourcecode gibt es hier:
http://www.alcpu.com/forums/viewforum.php?f=36
------------------------------------------------------------
Für SAMURIZE - Fans:

A plugin for AMD and INTEL CPUs shows CORE temperatures and more...

Hi,
since the CORETEMP-Program has the SHARED MEMORY FEATURE,
it's now easy to get all the values of CORETEMP.
SAMURIZE needs the coretemp.dll-plugin in the plugin-folder
AND the CORETEMP.exe running.
Download the plugin here:
http://www.samurize.com/modules/mydo...cid=6&lid=2188
and CORETEMP there:
http://www.alcpu.com/CoreTemp/

Have fun!
Tiu Hathor

Exported functions:

exports Init name 'init';
exports getparam name 'getparam';
exports core0 name 'core0';
exports core1 name 'core1';
exports core2 name 'core2';
exports core3 name 'core3';
exports ucore0 name 'ucore0';
exports ucore1 name 'ucore1';
exports ucore2 name 'ucore2';
exports ucore3 name 'ucore3';
exports CPUname name 'CPUname';
exports CPUspeed name 'CPUspeed';
exports GetCPUspeed name 'GetCPUspeed';
exports CPUmaxspeed name 'CPUmaxspeed';
exports TjMax name 'TjMax';
exports CpuCoreCount name 'CpuCoreCount';
exports CpuCount name 'CpuCount';
exports CpuVID name 'CpuVID';
exports CpuFSBSpeed name 'CpuFSBSpeed';
exports CpuMultiplier name 'CpuMultiplier';
exports Fahrenheit name 'Fahrenheit';
exports DeltaToTjMax name 'DeltaToTjMax';
exports hathor name 'hathor';
exports getinfo name 'getinfo';
exports dlltype name 'dlltype';

hathor 28. Mai 2008 10:29

Re: CORETEMP mit Shared Memory
 
Delphi-Quellcode:
{
    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.

bluescreen25 7. Jun 2009 00:08

Re: CORETEMP mit Shared Memory
 
Habe mich mal an der aktuellen dll versucht. Wenn ich das richtig verstanden habe, benötigt man nicht mehr das starten der CoreTemp.exe

Ich komme zur Zeit nicht weiter, beim Aufruf von
Delphi-Quellcode:
if GetCoreInfo(NewCoreTempInfo)...
bekomme ich false zurück. Anscheinend ist meine Übergabe der Daten fehlerhaft...

Jemand eine Idee ?

Hier der Link zur C++ Info: Core Temp mit Dll



Delphi-Quellcode:
unit CoreTempUnit;

interface

uses
  Windows;


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;
 
 TFNGetCoreInfo = function(Data: PCTInfo):boolean; stdcall;


function LoadCoreTempDLL:Boolean;
function UnloadCoreTempDLL:Boolean;

var
  NewCoreTempInfo  : PCTInfo;
  GetCoreInfo      : TFNGetCoreInfo = nil;
  CoreLib          : HMODULE;


implementation


function LoadCoreTempDLL:Boolean;
begin
  result := false;
  Corelib := LoadLibrary('GetCoreTempInfo.dll');
  if Corelib <> 0 then
  begin
    @GetCoreInfo := GetProcAddress(Corelib, 'fnGetCoreTempInfoAlt');
    result := true;
  end;
end;


function UnloadCoreTempDLL:Boolean;
begin
  if CoreLib <> 0 then
  begin
    FreeLibrary(CoreLib);
    result := True;
  end else
    result := False;
end;
Gruß, bluescreen25

hathor 7. Jun 2009 20:04

Re: CORETEMP mit Shared Memory
 
Zitat:

Zitat von bluescreen25
Habe mich mal an der aktuellen dll versucht. Wenn ich das richtig verstanden habe, benötigt man nicht mehr das starten der CoreTemp.exe...
Gruß, bluescreen25

Da hast Du etwas falsch verstanden!
SHARED MEMORY wird von CORETEMP.EXE mit Daten gefüllt gemäss der obengenannten Struktur. Ob man die Daten danach mit der DLL oder mit meinem DELPHI-Code ausliest macht keinen Unterschied. Aber wenn man mit DELPHI programmiert, wozu dann den Umweg über die DLL?

Weitere Infos:

http://www.alcpu.com/forums/viewforum.php?f=36

bluescreen25 7. Jun 2009 21:12

Re: CORETEMP mit Shared Memory
 
Zitat:

Zitat von hathor
Zitat:

Zitat von bluescreen25
Habe mich mal an der aktuellen dll versucht. Wenn ich das richtig verstanden habe, benötigt man nicht mehr das starten der CoreTemp.exe...
Gruß, bluescreen25

Da hast Du etwas falsch verstanden!
SHARED MEMORY wird von CORETEMP.EXE mit Daten gefüllt gemäss der obengenannten Struktur. Ob man die Daten danach mit der DLL oder mit meinem DELPHI-Code ausliest macht keinen Unterschied. Aber wenn man mit DELPHI programmiert, wozu dann noch die DLL laden?

OK, inzwischen nach einigen Recherchen ist mir das klar. Trotz alledem ist das mit der dll noch nicht gelöst. Hast du eine Lösung in meinem Code ?

Gruß,bluescreen

hathor 13. Sep 2014 15:05

AW: CORETEMP mit Shared Memory
 
Liste der Anhänge anzeigen (Anzahl: 3)
Die SHARED MEMORY-Struktur wurde vor einiger Zeit erweitert, weil in den CPUs mehr Funktionen enthalten sind, z. B. die Leistungsaufnahme.
Siehe:
http://www.alcpu.com/CoreTemp/developers.html

Download:
http://www.alcpu.com

Im Anhang sind EXE, Sourcecode und eine aktuelle CORETEMP-Version
- aber NUR die 64Bit-Version
- installiert werden muss nichts. Das Original enthält unnützes Zeugs...

Delphi-Quellcode:
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.

Luckie 13. Sep 2014 16:51

AW: CORETEMP mit Shared Memory
 
Bei mir zeigt dein Programm leider gar nichts an unter Windows 7. Auch wenn ich es als Admin starte nicht.

hathor 13. Sep 2014 17:28

AW: CORETEMP mit Shared Memory
 
Core Temp.exe läuft? Siehe Task Manager.
Denn das Programm füttert das SHARED MEMORY mit Daten...

Bei mir läuft es unter WIN8.0

Luckie 13. Sep 2014 17:42

AW: CORETEMP mit Shared Memory
 
Ich sehe das Fenster. Es wird nur nichts angezeigt.

hathor 13. Sep 2014 18:03

AW: CORETEMP mit Shared Memory
 
Welche Core Temp.exe-Version?
Ältere (0.99 und älter) haben diese Erweiterung noch nicht.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:13 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz