Examples Delphi

Title: How to send/get the priority of a process.
Question: Change the priority that Windows gives to your application or get what priority it has.
BE WARNED: YOUR APPLICATION CAN BLOCK THE OPERATING SYSTEM!!!
Answer:
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;
Use this:
Function SetProcessPriority( Priority : Integer ) : Integer;
to set a priority to your application, or this:
Function GetProcessPriority : Integer;
to get the actual priority.