Einzelnen Beitrag anzeigen

Kapitan Bomba

Registriert seit: 7. Nov 2008
Ort: Friedrichsdorf
13 Beiträge
 
#8

Re: Windows 7 Prozessorauslastung auslesen / Lautstärke rege

  Alt 15. Jan 2010, 18:17
Delphi-Quellcode:
...
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 "<-- Bei dieser Zeile flieg ich raus"
    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
... ...
  Mit Zitat antworten Zitat