AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Windows Leistungsindex

Ein Thema von PeterPanino · begonnen am 8. Sep 2018 · letzter Beitrag vom 10. Sep 2018
 
PeterPanino

Registriert seit: 4. Sep 2004
1.472 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: Windows Leistungsindex

  Alt 8. Sep 2018, 21:19
Kann jemand bitte mal testen, ob das auf seinem System funktioniert? Auf meinem System funktioniert es nämlich nicht - Ergebnis ist immer -1,00

Delphi-Quellcode:
program TestConsoleApplication;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  CodeSiteLogging,
  WbemScripting_TLB,
  ActiveX,
  System.Variants,
  System.SysUtils;

function GetWMIstring(wmiHost, wmiClass, wmiProperty: string): string;
var
  // These are all needed for the WMI querying process
  Locator: ISWbemLocator;
  Services: ISWbemServices;
  SObject: ISWbemObject;
  ObjSet: ISWbemObjectSet;
  SProp: ISWbemProperty;
  Enum: IEnumVariant;
  Value: Cardinal;
  TempObj: OleVariant;
  SN: string;
begin
  Result := '';
  try
    // Create the Location object
    Locator := CoSWbemLocator.Create;
    // Connect to the WMI service, with the root\cimv2 namespace
    Services := Locator.ConnectServer(wmiHost, 'root\cimv2', '', '', '', '', 0, nil);
    ObjSet := Services.ExecQuery('SELECT * FROM ' + wmiClass, 'WQL', wbemFlagReturnImmediately and wbemFlagForwardOnly, nil);
    Enum := (ObjSet._NewEnum) as IEnumVariant;

    while Enum.Next(1, TempObj, Value) = S_OK do
    begin

      try
        SObject := IUnknown(TempObj) as ISWBemObject;
      except
        SObject := nil;
      end;
      // Always need to free interface in TempObj
      TempObj := System.Variants.Unassigned;

      if SObject <> nil then
      begin
        SProp := SObject.Properties_.Item(wmiProperty, 0);
        SN := SProp.Get_Value;

        if not VarIsNull(SN) then
        begin
          Result := SN;
          Break;
        end;

      end;
    end;
    // Trap any exceptions (Like not having WMI installed will cause one...)
  except
  end;
end;

begin
  try

    CodeSite.Send('Start');
    CodeSite.Send('CPUScore', Format('%.2f', [StrToFloatDef(GetWMIstring('', 'Win32_WinSAT', 'CPUScore'), -1)]));
    CodeSite.Send('WinSPRLevel', Format('%.2f', [StrToFloatDef(GetWMIstring('', 'Win32_WinSAT', 'WinSPRLevel'), -1)]));

  except
    on E: Exception do
    begin
      Writeln(E.ClassName, ': ', E.Message);
      Readln;
    end;
  end;
end.

Geändert von PeterPanino ( 8. Sep 2018 um 21:22 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es 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

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:12 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz