|
Antwort |
hathor
Der OPENHARDWAREMONITOR mit WMI-Server stellt die Daten für weitere Verwendung zur Verfügung.
http://openhardwaremonitor.org/ Leider enthält er einige kleine Fehler, z.B. einige Bezeichnungen sind falsch... Die Variable OHM : Boolean; hat in dieser DEMO keine Bedeutung.
Delphi-Quellcode:
Tags:
unit Unit2; //2ß140914
interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, ActiveX, ComObj, Vcl.OleAuto; type TForm2 = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; procedure Button1Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form2: TForm2; OHM : Boolean; const WbemUser =''; WbemPassword =''; WbemComputer ='localhost'; wbemFlagForwardOnly = $00000020; implementation {$R *.dfm} procedure MM(s:string); begin Form2.Memo1.Lines.Add(s); end; procedure TForm2.Button1Click(Sender: TObject); begin Close; end; procedure GetSensorInfo; var FSWbemLocator, FWMIService, FWbemObjectSet, FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\OpenHardwareMonitor', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Sensor','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin MM(Format(' Identifier %s',[String(FWbemObject.Identifier)]));// String MM(Format(' Index %d',[Integer(FWbemObject.Index)]));// Sint32 MM(Format(' InstanceId %s',[String(FWbemObject.InstanceId)]));// String MM(Format(' Max %n',[Double(FWbemObject.Max)]));// Real32 MM(Format(' Min %n',[Double(FWbemObject.Min)]));// Real32 MM(Format(' Name %s',[String(FWbemObject.Name)]));// String MM(Format(' Parent %s',[String(FWbemObject.Parent)]));// String MM(Format(' ProcessId %s',[String(FWbemObject.ProcessId)]));// String MM(Format(' SensorType %s',[String(FWbemObject.SensorType)]));// String MM(Format(' Value %n',[Double(FWbemObject.Value)]));// Real32 MM('----------------------------------------------------------------------'); end; FWbemObject:=Unassigned; end; procedure GetSensorCPUTEMP; var FSWbemLocator, FWMIService, FWbemObjectSet, FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; OHM:= false; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\OpenHardwareMonitor', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Sensor WHERE Name LIKE "%CPU %" AND SensorType = "Temperature"','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin MM(Format(' Name: %s',[String(FWbemObject.Name)]));// String MM(Format(' SensorType %s',[String(FWbemObject.SensorType)]));// String MM(Format(' Value: %n',[Double(FWbemObject.Value)]));// Real32 MM(''); end; OHM:= true; FWbemObject:=Unassigned; end; procedure GetSensorCPULOAD; var FSWbemLocator, FWMIService, FWbemObjectSet, FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; OHM:= false; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\OpenHardwareMonitor', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Sensor WHERE Name LIKE "%CPU %" AND SensorType = "Load"','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin MM(Format(' Name: %s',[String(FWbemObject.Name)]));// String MM(Format(' SensorType %s',[String(FWbemObject.SensorType)]));// String MM(Format(' Value: %n',[Double(FWbemObject.Value)]));// Real32 MM(''); end; OHM:= true; FWbemObject:=Unassigned; end; procedure GetSensorHDD; var FSWbemLocator, FWMIService, FWbemObjectSet, FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; OHM:= false; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\OpenHardwareMonitor', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Sensor WHERE Name = "Temperature" AND SensorType = "Temperature"','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin MM(Format(' Name: %s',[String(FWbemObject.Name)]));// String MM(Format(' SensorType %s',[String(FWbemObject.SensorType)]));// String MM(Format(' Value: %n',[Double(FWbemObject.Value)]));// Real32 end; OHM:= true; FWbemObject:=Unassigned; end; procedure GetSensorGPU; var FSWbemLocator, FWMIService, FWbemObjectSet, FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; OHM:= false; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\OpenHardwareMonitor', WbemUser, WbemPassword); FWbemObjectSet:= // FWMIService.ExecQuery('SELECT * FROM Sensor WHERE Name LIKE "%GPU Core%" AND SensorType = "Temperature"','WQL',wbemFlagForwardOnly); // FWMIService.ExecQuery('SELECT * FROM Sensor WHERE Name LIKE "%GPU %" AND SensorType = "Temperature"','WQL',wbemFlagForwardOnly); FWMIService.ExecQuery('SELECT * FROM Sensor WHERE Name LIKE "%GPU %"','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin MM(Format(' Name: %s',[String(FWbemObject.Name)]));// String MM(Format(' SensorType %s',[String(FWbemObject.SensorType)]));// String MM(Format(' Value: %n',[Double(FWbemObject.Value)]));// Real32 MM(''); end; OHM:= true; FWbemObject:=Unassigned; end; procedure TForm2.Button2Click(Sender: TObject); //HDD begin Memo1.Clear; GetSensorHDD; end; procedure TForm2.Button3Click(Sender: TObject); begin Memo1.Clear; GetSensorInfo; end; procedure TForm2.Button4Click(Sender: TObject); begin Memo1.Clear; GetSensorGPU; end; procedure TForm2.Button5Click(Sender: TObject); begin Memo1.Clear; GetSensorCPUTEMP; end; procedure TForm2.Button6Click(Sender: TObject); begin Memo1.Clear; GetSensorCPULOAD; end; procedure TForm2.FormCreate(Sender: TObject); begin Form2.Height:= Screen.Height-20; Memo1.Height:= Screen.Height-80; end; procedure TForm2.FormShow(Sender: TObject); begin Application.Title := 'OHM-2014'; GetSensorInfo; end; end. CPU, GPU, HDD Temperaturen und sonstiges Temperaturen lesen (CPU,HDD...) Geändert von hathor (14. Sep 2014 um 11:18 Uhr) |
hathor |
t.roller
|
#11
Hallo
Betriebssystem Windows 10 Auch wenn ich Delphi unter Admin Rechte starte. Hat jemand eine Idee ?? Ich habe erst die openhardwaremonitor-v0.8.0-beta benutzt und nun die openhardwaremonitor-v0.7.1-beta Leider ohne Erfolg. dann OHM.exe vom TE starten - braucht keine Adminrechte! Funktioniert auch mit WIN10. |
Zitat |
Ansicht |
Linear-Darstellung |
Zur Hybrid-Darstellung wechseln |
Zur Baum-Darstellung wechseln |
ForumregelnEs ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus. Trackbacks are an
Pingbacks are an
Refbacks are aus
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
LinkBack URL |
About LinkBacks |