Как получить или установить приоритет процесса в Win9x или Me

{codecitation class=»brush: pascal; gutter: false;» width=»600px»}

const

ppIdle : Integer = -1;

ppNormal : Integer = 0;

ppHigh : Integer = 1;

ppRealTime : Integer = 2;

function SetProcessPriority( Priority : Integer ) : Integer;

var

H : THandle;

begin

Result := ppNormal;

H := GetCurrentProcess();

if ( Priority = ppIdle ) then

SetPriorityClass( H, IDLE_PRIORITY_CLASS )

else

if ( Priority = ppNormal ) then

SetPriorityClass( H, NORMAL_PRIORITY_CLASS )

else

if ( Priority = ppHigh ) then

SetPriorityClass( H, HIGH_PRIORITY_CLASS )

else

if ( Priority = ppRealTime ) then

SetPriorityClass( H, REALTIME_PRIORITY_CLASS );

case GetPriorityClass( H ) of

IDLE_PRIORITY_CLASS : Result := ppIdle;

NORMAL_PRIORITY_CLASS : Result := ppNormal;

HIGH_PRIORITY_CLASS : Result := ppHigh;

REALTIME_PRIORITY_CLASS : Result := ppRealTime;

end;

end;

function GetProcessPriority : Integer;

var

H : THandle;

begin

Result := ppNormal;

H := GetCurrentProcess();

case GetPriorityClass( H ) of

IDLE_PRIORITY_CLASS : Result := ppIdle;

NORMAL_PRIORITY_CLASS : Result := ppNormal;

HIGH_PRIORITY_CLASS : Result := ppHigh;

REALTIME_PRIORITY_CLASS : Result := ppRealTime;

end;

end;

Как использовать:

function SetProcessPriority( Priority : Integer ) : Integer;

для установки приоритета Вашего приложения, либо:

function GetProcessPriority : Integer;

для получения приоритета.

{/codecitation}

Добавить комментарий