Einzelnen Beitrag anzeigen

Benutzerbild von smallsmoker
smallsmoker

Registriert seit: 12. Nov 2007
Ort: Duisburg
283 Beiträge
 
#4

Re: CallNTPowerInformation unter Vista

  Alt 9. Feb 2009, 17:54
für cpu infos benutze ich
Delphi-Quellcode:
function GetCPUCount: DWord;
var
  SysInfo: TSystemInfo;
begin
  GetSystemInfo(SysInfo);
  Result := SysInfo.dwNumberOfProcessors;
end;

function CPUClock(const intDelayTime: integer = 50): double;
var
  TimerHi, TimerLo: DWORD;
  PriorityClass, Priority: Integer;
begin
  // saves thread priority for the process
  PriorityClass := GetPriorityClass(GetCurrentProcess);
  Priority := GetThreadPriority(GetCurrentThread);

  // sets priority to REAL-TIME
  SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
  SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);

  // "delay" for priority effect
  Sleep(10);

  asm
    dw 310Fh // rdtsc
    mov TimerLo, eax
    mov TimerHi, edx
  end;

  // waits for calculations
  Sleep(intDelayTime);

  asm
    dw 310Fh // rdtsc
    sub eax, TimerLo
    sbb edx, TimerHi
    mov TimerLo, eax
    mov TimerHi, edx
  end;

  // restores process priority
  SetThreadPriority(GetCurrentThread, Priority);
  SetPriorityClass(GetCurrentProcess, PriorityClass);

  // sets the result with CPU clock frequency
  result := TimerLo / (1000.0 * intDelayTime);
end;
  Mit Zitat antworten Zitat