Autor |
Beitrag |
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: So 13.01.13 21:07
Guten Abend,
ich weiß, es schwirrt sehr viel über dieses Thema im Internet rum, doch irgendwie komme ich nicht zu einem Ergebnis
Habe diesen Code hier gefunden ( stackoverflow.com/qu...d-and-monitor-the-te):
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137:
| program CPUTemp;
{$APPTYPE CONSOLE}
uses SysUtils, Dialogs, ActiveX, Variants, WbemScripting_TLB;
procedure ShowTemperatureInfo(); var WMIServices: ISWbemServices; Root : ISWbemObjectSet; Item : Variant; I : Integer; begin
Writeln('Temperature Info'); Writeln('----------------');
WMIServices := CoSWbemLocator.Create.ConnectServer('.', 'root\cimv2','', '', '', '', 0, nil); Root := WMIServices.ExecQuery('Select * FROM Win32_TemperatureProbe','WQL', 0, nil);
for I := 0 to Root.Count - 1 do begin Item := Root.ItemIndex(I); Writeln('Accuracy '+VarToStr(Item.Accuracy)); Writeln('Availability '+VarToStr(Item.Availability)); Writeln('Caption '+Item.Caption); Writeln('Config Manager Error Code '+VarToStr(Item.ConfigManagerErrorCode)); Writeln('Config Manager User Config '+VarToStr(Item.ConfigManagerUserConfig)); Writeln('Creation Class Name '+VarToStr(Item.CreationClassName)); Writeln('Current Reading '+VarToStr(Item.CurrentReading)); Writeln('Description '+VarToStr(Item.Description)); Writeln('Device ID '+VarToStr(Item.DeviceID)); Writeln('Error Cleared '+VarToStr(Item.ErrorCleared )); Writeln('Error Description '+VarToStr(Item.ErrorDescription)); Writeln('Install Date '+VarToStr(Item.InstallDate)); Writeln('Is Linear '+VarToStr(Item.IsLinear)); Writeln('Last Error Code '+VarToStr(Item.LastErrorCode)); Writeln('Lower Threshold Critical '+VarToStr(Item.LowerThresholdCritical)); Writeln('Lower Threshold Fatal '+VarToStr(Item.LowerThresholdFatal)); Writeln('Lower Threshold NonCritical '+VarToStr(Item.LowerThresholdNonCritical)); Writeln('Max Readable '+VarToStr(Item.MaxReadable)); Writeln('Min Readable '+VarToStr(Item.MinReadable)); Writeln('Name '+VarToStr(Item.Name)); Writeln('Nominal Reading '+VarToStr(Item.NominalReading)); Writeln('Normal Max '+VarToStr(Item.NormalMax)); Writeln('Normal Min '+VarToStr(Item.NormalMin )); Writeln('PNP Device ID '+VarToStr(Item.PNPDeviceID)); Writeln('Power Management Capabilities '+VarToStr(Item.PowerManagementCapabilities)); Writeln('Power Management Supported '+VarToStr(Item.PowerManagementSupported)); Writeln('Resolution '+VarToStr(Item.Resolution)); Writeln('Status '+VarToStr(Item.Status)); Writeln('Status Info '+VarToStr(Item.StatusInfo)); Writeln('System Creation Class Name '+VarToStr(Item.SystemCreationClassName)); Writeln('System Name '+VarToStr(Item.SystemName)); Writeln('Tolerance '+VarToStr(Item.Tolerance)); Writeln('Upper Threshold Critical '+VarToStr(Item.UpperThresholdCritical)); Writeln('Upper Threshold Fatal '+VarToStr(Item.UpperThresholdFatal)); Writeln('Upper Threshold NonCritical '+VarToStr(Item.UpperThresholdNonCritical)); Writeln(''); end; end;
procedure ShowCPUFanInfo(); var WMIServices: ISWbemServices; Root : ISWbemObjectSet; Item : Variant; I : Integer; begin Writeln('CPU FAN Info'); Writeln('----------------'); WMIServices := CoSWbemLocator.Create.ConnectServer('.', 'root\cimv2','', '', '', '', 0, nil); Root := WMIServices.ExecQuery('Select * FROM Win32_Fan','WQL', 0, nil); for I := 0 to Root.Count - 1 do begin Item := Root.ItemIndex(I);
Writeln('ActiveCooling '+VarToStr(Item.ActiveCooling)); Writeln('Availability '+VarToStr(Item.Availability)); Writeln('Caption '+VarToStr(Item.Caption)); Writeln('Config Manager ErrorCode '+VarToStr(Item.ConfigManagerErrorCode)); Writeln('Config Manager UserConfig '+VarToStr(Item.ConfigManagerUserConfig)); Writeln('Creation ClassName '+VarToStr(Item.CreationClassName)); Writeln('Description '+VarToStr(Item.Description)); Writeln('DesiredSpeed '+VarToStr(Item.DesiredSpeed)); Writeln('DeviceID '+VarToStr(Item.DeviceID)); Writeln('ErrorCleared '+VarToStr(Item.ErrorCleared)); Writeln('ErrorDescription '+VarToStr(Item.ErrorDescription)); Writeln('InstallDate '+VarToStr(Item.InstallDate)); Writeln('LastErrorCode '+VarToStr(Item.LastErrorCode)); Writeln('Name '+VarToStr(Item.Name)); Writeln('PNPDeviceID '+VarToStr(Item.PNPDeviceID)); Writeln('PowerManagement Capabilities '+VarToStr(Item.PowerManagementCapabilities)); Writeln('PowerManagement Supported '+VarToStr(Item.PowerManagementSupported)); Writeln('Status '+VarToStr(Item.Status)); Writeln('StatusInfo '+VarToStr(Item.StatusInfo)); Writeln('SystemCreation ClassName '+VarToStr(Item.SystemCreationClassName)); Writeln('SystemName '+VarToStr(Item.SystemName)); Writeln('VariableSpeed '+VarToStr(Item.VariableSpeed)); Writeln(''); end;
End;
begin try CoInitialize(nil); ShowTemperatureInfo(); ShowCPUFanInfo(); Readln; CoUninitialize; except on E:Exception do Begin CoUninitialize; Writeln(E.Classname, ': ', E.Message); Readln; End; end; end. |
Doch das Objekt ISWbemObjectSet hat die Anzahl 0. Von dem her bekomme ich eben keine Daten ^^ Hat jemand eine Ahnung, woran das liegt? Habe ein Mainboard von ASRock.
Viele Grüße
Littleben
|
|
jaenicke
Beiträge: 19284
Erhaltene Danke: 1742
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 13.01.13 21:16
Die CPU-Temperatur wurde zwar von Microsoft in WMI angeboten, aber die meisten Hersteller liefern diese nicht dorthin, vermutlich um ihre eigenen Überwachungslösungen zu fördern.
Es gibt Komponenten für Delphi für rund 100 Euro, die die einzelnen Chipsätze der verschiedenen Hersteller entsprechend ansprechen. Selbst so etwas zu implementieren ist vom Aufwand her kaum machbar...
// EDIT:
Ach ja, Tools wie der WMI Explorer helfen dabei zu schauen, ob tatsächlich keine Daten vorhanden sind:
www.heise.de/downloa...xplorer-1169189.html
|
|
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: So 13.01.13 21:29
Geht bei WMI mit WIN VISTA oder WIN 7 nicht ohne Admin-Rechte.
Programm im Anhang starten mit Als Administrator ausführen.
.
Mit WIN XP:
www.entwickler-ecke....amp;highlight=hathor
www.entwickler-ecke....amp;highlight=hathor
.
Mit WIN 7 und ältere Versionen:
www.entwickler-ecke....amp;highlight=hathor
Einloggen, um Attachments anzusehen!
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Fr 18.01.13 16:07
Und wie geht es mit Adminrechte?
|
|
Blawen
Beiträge: 616
Erhaltene Danke: 33
Win XP, Vista, 7
Delphi 5 Prof., BDS 2006 Prof. RAD Studio XE
|
Verfasst: So 20.01.13 02:00
_________________ Es kompilert, wir können ausliefern.
Und es kompiliert wieder - das Update ist fertig - bitte 100 Euro
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: So 20.01.13 11:45
Troll Das meinte ich nicht wirklich ^^
Wenn ich das richtig verstanden habe, dann liefert mir nach der Methode, die hathor gepostet hat, CoreTemp die benötigten Daten. Aber wenn ich dafür schon ein Programm schreibe, dann möchte ich ja nicht immer noch ein anderes Programm laufen haben müssen...
Wie liest CoreTemp eigentlich die Daten aus?
|
|
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: So 20.01.13 15:02
Mit DELPHI allein geht es nicht.
Man muss die CPU-Register auslesen, z.B. MSR 0x19C bei INTEL.
Dafür braucht man winring0.dll, winring0.sys, bzw. WinRing0x64.dll, WinRing0x64.sys.
www.alcpu.com/CoreTemp/howitworks.html
Hier ist
openhardwaremonitor.org/
Sourcecode in C# - da kannst Du sehen, wie es mit readmsr gemacht wird.
code.google.com/p/op.../browse/#svn%2Ftrunk
code.google.com/p/op...ware/CPU/IntelCPU.cs
|
|
Blawen
Beiträge: 616
Erhaltene Danke: 33
Win XP, Vista, 7
Delphi 5 Prof., BDS 2006 Prof. RAD Studio XE
|
Verfasst: So 20.01.13 17:35
_________________ Es kompilert, wir können ausliefern.
Und es kompiliert wieder - das Update ist fertig - bitte 100 Euro
|
|
Bergmann89
Beiträge: 1742
Erhaltene Danke: 72
Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
|
Verfasst: Mo 21.01.13 19:55
Hey,
ich hab das damals über den OpenHardwareMonitor gemacht, der schreibt seine Daten auch in die WMI. Ist dann zwar ein extra Programm welches immer im Hintergrund läuft, aber so hat man relativ wenig Aufwand. Kann sein das du für den WMI Support den neusten Stand aus'm Repo kompilieren musst. Bei mir war der damals noch nich im Release mit drin.
MfG Bergmann.
_________________ Ich weiß nicht viel, lern aber dafür umso schneller^^
|
|
|