Как получить / установить приоритет процесса в
Win9x/Me
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;
для получения приоритета.
|