[an error occurred while processing this directive]
[an error occurred while processing this directive]
|
var
PriorityClass, Priority: Integer;
DelayCount : dword;
{---------------------------------}
{ Калибровка скорости работы компьютера }
procedure CalibrDelay;
var
PriorityClass, Priority : integer;
i, L, RN, RK : dword;
begin
PriorityClass := GetPriorityClass ( GetCurrentProcess );
Priority := GetThreadPriority ( GetCurrentThread );
{ Определение количества циклов задержки на мкс }
SetPriorityClass ( GetCurrentProcess, REALTIME_PRIORITY_CLASS );
SetThreadPriority ( GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL );
L := 1000;
Repeat
L := L * 10;
RN := GetTickCount;
For i := 1 to L do;
RK := GetTickCount;
until ( RK - RN ) > 100;
DelayCount := Round ( L / 1000 / ( RK - RN ) );
If DelayCount = 0
then DelayCount := 1;
SetThreadPriority ( GetCurrentThread, Priority );
SetPriorityClass ( GetCurrentProcess, PriorityClass );
end; { CalibrDelay }
{---------------------------------}
{ Задержка на мкс }
procedure DelayUS ( US : dword );
var
i, L : dword;
begin
L := US * DelayCount;
For i := 1 to L do;
end; { TMainForm.DelayUS }
{---------------------------------}
// Сделать приложение "единственным"
procedure SetRealTimePriority;
begin
PriorityClass := GetPriorityClass ( GetCurrentProcess );
Priority := GetThreadPriority ( GetCurrentThread );
SetPriorityClass ( GetCurrentProcess, REALTIME_PRIORITY_CLASS );
SetThreadPriority ( GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL );
end; // SetRealTimePriority
{---------------------------------}
// Восстановить нормальный приоритет
procedure ClrRealTimePriority;
begin
SetThreadPriority ( GetCurrentThread, Priority );
SetPriorityClass ( GetCurrentProcess, PriorityClass );
end; // ClrRealTimePriority
Процедурки задержек должны быть взяты с скобки
SetRealTimePriority;
ClrRealTimePriority;
Большой точности не обещается, но подстройка под конкретную машину наличествует.
E-mail: info@telesys.ru