Set priority level of running application (process)

Using SetPriorityClass function, you can set priority level of your running application. Same functionality is in the Task Manager (just rightclick the process in the list and select priority level).

procedure SetPriorityLevel(P: byte);
begin
  case p of
  1: Setpriorityclass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
  2: Setpriorityclass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
  3: Setpriorityclass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
  4: Setpriorityclass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
  end;
end;

Just call this procedure with parameter of priority level you want to set. Here are just four levels of priority because of compatibility in all Windows versions. However, you can find whole list of possible constants here.

Leave a Reply