Taktowanie procesora w delphi 7!!

0

Otóz mam pytanko.Podałem kod:

const
 DelayTime = 500;
var
 TimerHi, TimerLo: DWORD;
 PriorityClass, Priority: integer;
begin
PriorityClass := GetPriorityClass(GetCurrentProcess);
 Priority := GetThreadPriority(GetCurrentThread);

 SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
 SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);

 Sleep(10);
 asm 
  dw 310Fh // rdtsc
  mov TimerLo, eax 
  mov TimerHi, edx 
 end;
 Sleep(DelayTime); 
 asm 
  dw 310Fh // rdtsc
  sub eax, TimerLo 
  sbb edx, TimerHi 
  mov TimerLo, eax
  mov TimerHi, edx 
 end; 

 SetThreadPriority(GetCurrentThread, Priority); 
 SetPriorityClass(GetCurrentProcess, PriorityClass); 

 Result := integer(Round((TimerLo / (1000.0 * DelayTime)))); 
end;


end;

end.

Ale przy tym: wywala mi błąd!!.Dlaczego jesli ktos wie!!<font color="red">ShowMessage(IntToStr(CheckCPUSpeed) + ' MHz');</span>

0

Niedawno umiescilem w artach lub FAqach kod na pobranie predkosci procka...zajrzyj

0

To musi działać :

nie wpisałeś na początku :
function CheckCPUSpeed: integer;

i na <ort>kącu </ort>jeden End; za dużo.

Gdzie wpisujesz to
ShowMessage(IntToStr(CheckCPUSpeed) + ' MHz');

powinno być np w onclick buttona.

0

Ja mam taki kod:

function GetCPUSpeed: Double; 
const 
  DelayTime = 500; 
var 
  TimerHi, TimerLo: DWORD; 
  PriorityClass, Priority: Integer; 
begin 
  PriorityClass := GetPriorityClass(GetCurrentProcess); 
  Priority      := GetThreadPriority(GetCurrentThread); 

  SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS); 
  SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL); 

  Sleep(10); 
  asm 
    dw 310Fh 
    mov TimerLo, eax 
    mov TimerHi, edx 
  end; 
  Sleep(DelayTime); 
  asm 
    dw 310Fh 
    sub eax, TimerLo 
    sbb edx, TimerHi 
    mov TimerLo, eax 
    mov TimerHi, edx 
  end; 

  SetThreadPriority(GetCurrentThread, Priority); 
  SetPriorityClass(GetCurrentProcess, PriorityClass); 

  Result := TimerLo / (1000 * DelayTime); 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
  ShowMessage(Format('Your CPU speed: %f MHz', [GetCPUSpeed])); 
end; 

U mnie on dziala a wiec porownaj go ze swoim i wszystko jasne [cya]

1 użytkowników online, w tym zalogowanych: 0, gości: 1