Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#7

AW: Aktuelle CPUFrequenz abfragen (SpeedStep)

  Alt 10. Nov 2015, 19:19
Die WMI-Funktion ist ohne Refresher nicht nutzbar.

Delphi-Quellcode:
// Version: 1.8.3.0
// LIABILITY DISCLAIMER
// THIS GENERATED CODE IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED.
// YOU USE IT AT YOUR OWN RISK. THE AUTHOR NOT WILL BE LIABLE FOR DATA LOSS,
// DAMAGES AND LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS CODE.
//----------------------------------------------------------------------------------------------------
program GetWMI_Info;

{$APPTYPE CONSOLE}

uses
 // SysUtils, ActiveX, ComObj, Variants;
  System.SysUtils,
  Winapi.ActiveX,
  System.Win.ComObj,
  System.Variants;

const
  WbemUser =''; WbemPassword =''; WbemComputer ='localhost';
  wbemFlagForwardOnly = $00000020;

function VarToInt(const AVariant: Variant): INT64;// integer;
begin Result := StrToIntDef(Trim(VarToStr(AVariant)), 0); end;

procedure GetCIM_ProcessorInfo;
var
  FSWbemLocator : OLEVariant;
  FWMIService : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject : OLEVariant;
  oEnum : IEnumvariant;
  iValue : LongWord;
begin;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM CIM_Processor','WQL',wbemFlagForwardOnly);
  oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  while oEnum.Next(1, FWbemObject, iValue) = 0 do
  begin
    Writeln(Format('AddressWidth %d',[VarToInt(FWbemObject.AddressWidth)]));// Uint16
    Writeln(Format('Availability %d',[VarToInt(FWbemObject.Availability)]));// Uint16
    Writeln(Format('Caption %s',[VarToStr(FWbemObject.Caption)]));// String
    Writeln(Format('ConfigManagerErrorCode %d',[VarToInt(FWbemObject.ConfigManagerErrorCode)]));// Uint32
    Writeln(Format('ConfigManagerUserConfig %s',[VarToStr(FWbemObject.ConfigManagerUserConfig)]));// Boolean
    Writeln(Format('CreationClassName %s',[VarToStr(FWbemObject.CreationClassName)]));// String
    Writeln(Format('CurrentClockSpeed %d',[VarToInt(FWbemObject.CurrentClockSpeed)]));// Uint32
    Writeln(Format('DataWidth %d',[VarToInt(FWbemObject.DataWidth)]));// Uint16
    Writeln(Format('Description %s',[VarToStr(FWbemObject.Description)]));// String
    Writeln(Format('DeviceID %s',[VarToStr(FWbemObject.DeviceID)]));// String
    Writeln(Format('ErrorCleared %s',[VarToStr(FWbemObject.ErrorCleared)]));// Boolean
    Writeln(Format('ErrorDescription %s',[VarToStr(FWbemObject.ErrorDescription)]));// String
    Writeln(Format('Family %d',[VarToInt(FWbemObject.Family)]));// Uint16
    Writeln(Format('InstallDate %s',[VarToStr(FWbemObject.InstallDate)]));// Datetime
    Writeln(Format('LastErrorCode %d',[VarToInt(FWbemObject.LastErrorCode)]));// Uint32
    Writeln(Format('LoadPercentage %d',[VarToInt(FWbemObject.LoadPercentage)]));// Uint16
    Writeln(Format('MaxClockSpeed %d',[VarToInt(FWbemObject.MaxClockSpeed)]));// Uint32
    Writeln(Format('Name %s',[VarToStr(FWbemObject.Name)]));// String
    Writeln(Format('OtherFamilyDescription %s',[VarToStr(FWbemObject.OtherFamilyDescription)]));// String
    Writeln(Format('PNPDeviceID %s',[VarToStr(FWbemObject.PNPDeviceID)]));// String
    Writeln(Format('PowerManagementCapabilities %d',[VarToInt(FWbemObject.PowerManagementCapabilities)]));// Array of Uint16
    Writeln(Format('PowerManagementSupported %s',[VarToStr(FWbemObject.PowerManagementSupported)]));// Boolean
    Writeln(Format('Role %s',[VarToStr(FWbemObject.Role)]));// String
    Writeln(Format('Status %s',[VarToStr(FWbemObject.Status)]));// String
    Writeln(Format('StatusInfo %d',[VarToInt(FWbemObject.StatusInfo)]));// Uint16
    Writeln(Format('Stepping %s',[VarToStr(FWbemObject.Stepping)]));// String
    Writeln(Format('SystemCreationClassName %s',[VarToStr(FWbemObject.SystemCreationClassName)]));// String
    Writeln(Format('SystemName %s',[VarToStr(FWbemObject.SystemName)]));// String
    Writeln(Format('UniqueId %s',[VarToStr(FWbemObject.UniqueId)]));// String
    Writeln(Format('UpgradeMethod %d',[VarToInt(FWbemObject.UpgradeMethod)]));// Uint16

    Writeln('');
    FWbemObject:=Unassigned;
  end;
end;


begin
 try
    CoInitialize(nil);
    try
      GetCIM_ProcessorInfo;
    finally
      CoUninitialize;
    end;
 except
    on E:EOleException do
        Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
    on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;
end.
  Mit Zitat antworten Zitat