SetPriorityClass

  BOOL SetPriorityClass(hProcess, fdwPriority)    
  HANDLE hProcess; /* process to set priority for */
  DWORD fdwPriority; /* priority to set */

The SetPriorityClass function sets the priority class for the specified process.

Parameters

hProcess

Identifies the process to set the priority class for. The calling process must have PROCESS_SET_INFORMATION access to the process specified by hProcess when it calls this function.

fdwPriority

Specifies the new priority class for the specified process. This parameter may be one of the following values:

Value Meaning

IDLE_PRIORITY_CLASS  
  The process will only be run when the system is idle. An idle process will always be preempted by any process with a higher priority class. A screen-saver application is an example of an Idle priority process.
NORMAL_PRIORITY_CLASS  
  The process is a normal application with no special scheduling needs. This is the default priority class. Normal runnable processes will always preempt an Idle process; the idle process will only be scheduled when the normal process is blocked, and the normal process will preempt the idle process whenever the normal process can be run.
HIGH_PRIORITY_CLASS  
  The process is a high priority application. It has special scheduling needs that must be addressed in order for it to run correctly. One example of such a need would be a background application that is normally idle. In response to some external event, it needs to display a pop-up window pre-empting anything else that happens to be running in the normal or idle priority classes.
  Extreme care should be taken when using the high priority class. It is possible to create a CPU-bound application in the high priority class that can soak up nearly all available cycles.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

Using this function has a dramatic impact on the scheduling characteristics of the effected process. Applications should use this function carefully and understand the impact of making a process run in either the Idle or High priority classes.

See Also

GetPriorityClass