AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Wie kann ich die CPU auslastung in einer ProgressBar anzeige
Thema durchsuchen
Ansicht
Themen-Optionen

Wie kann ich die CPU auslastung in einer ProgressBar anzeige

Ein Thema von ObLtpatriz · begonnen am 12. Mai 2006 · letzter Beitrag vom 13. Mai 2006
 
ObLtpatriz

Registriert seit: 10. Mai 2006
Ort: Locarno /TI Schweiz
21 Beiträge
 
Delphi 2005 Personal
 
#1

Wie kann ich die CPU auslastung in einer ProgressBar anzeige

  Alt 12. Mai 2006, 23:56
Moin

Ich habe die Boardsuche und Google verwendet aber leider , nicht die gewünschte antwort zu meinem problem gefunden.


Ich verwende diesen quelltext um die CPU Auslastung in einer sich laufend aktualisierenden tahl anzuzeigen lassen.
Delphi-Quellcode:
  var
  Form: TForm;
  nOldIdleTime: Int64 = 0;
  nOldSystemTime : INT64 = 0;
  nNewCPUTime : ULONG = 0;

const
  SYS_BASIC_INFO = 0;
  SYS_PERFORMANCE_INFO = 2;
  SYS_TIME_INFO = 3;

type
  SYSTEM_BASIC_INFORMATION = packed record
    dwUnknown1 : DWORD;
    uKeMaximumIncrement : ULONG;
    uPageSize : ULONG;
    uMmNumberOfPhysicalPages: ULONG;
    uMmLowestPhysicalPage : ULONG;
    uMmHighestPhysicalPage : ULONG;
    uAllocationGranularity : ULONG;
    pLowestUserAddress : POINTER;
    pMmHighestUserAddress : POINTER;
    uKeActiveProcessors : POINTER;
    bKeNumberProcessors : BYTE;
    bUnknown2 : BYTE;
    wUnknown3 : WORD;
  end;

  SYSTEM_PERFORMANCE_INFORMATION = packed record
    nIdleTime : INT64;
    dwSpare : array[0..75]of DWORD;
  end;

  SYSTEM_TIME_INFORMATION = packed record
    nKeBootTime : INT64;
    nKeSystemTime : INT64;
    nExpTimeZoneBias : INT64;
    uCurrentTimeZoneId : ULONG;
    dwReserved : DWORD;
  end;

  function NTQuerySystemInformation(SystemInformationClass: Longint;
                                    SystemInformation: Pointer;
                                    SystemInformationLength: Longint;
                                    ReturnLength: Longint): Longint; stdcall;
                                    external 'ntdll.dllname 'NtQuerySystemInformation';




function GetCPUUsage: Integer;
var
  spi : SYSTEM_PERFORMANCE_INFORMATION;
  sti : SYSTEM_TIME_INFORMATION;
  sbi : SYSTEM_BASIC_INFORMATION;
begin
  result := 0;
  if (NTQuerySystemInformation(SYS_BASIC_INFO, @sbi, sizeof(SYSTEM_BASIC_INFORMATION), 0) = NO_ERROR) then
  begin
    if (NTQuerySystemInformation(SYS_TIME_INFO, @sti, sizeof(SYSTEM_TIME_INFORMATION), 0) = NO_ERROR) then
    if (NTQuerySystemInformation(SYS_PERFORMANCE_INFO, @spi, sizeof(SYSTEM_PERFORMANCE_INFORMATION), 0)= NO_ERROR) then
    begin
      if (nOldIdleTime <> 0) then
      begin
        nNewCPUTime:= trunc(100-((spi.nIdleTime-nOldIdleTime)/(sti.nKeSystemTime-nOldSystemTime)*100)/sbi.bKeNumberProcessors+0.5);
        if (nNewCPUTime <> nOldIdleTime) then
        begin
          Result := nNewCPUTIME;
        end;
      end;
      nOldIdleTime := spi.nIdleTime;
      nOldSystemTime := sti.nKeSystemTime;
    end;
  end;
end;


 procedure TWin2kAppForm.FormClick(Sender: TObject);
begin
  Label19.Caption := IntToStr(GetCPUUsage());
end;

procedure TWin2kAppForm.Button11Click(Sender: TObject);
begin
  Label19.Caption := IntToStr(GetCPUUsage());

end;
Was ist die Procedure(Quellcode) um mit dem oben genannten quelltext die CPU Auslastung auch in einer ProggressBar anzuzeigen.(TProgressBar)?
patrick
Am 08.05.2006 gestartet mit Delphi
  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 08:28 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 by Thomas Breitkreuz