tSetPriority

Sets priority class of a process.

 

Syntax:

tSetPriority ( process-id , priority class)

Parameters:

(i) process-id process-id of a particular process. (obtained by tListProc)

(i) priority class Priority flag. See below

Returns:

(i)  always 1

Note: Windows 2000 and newer : this function requires the following process-specific access right PROCESS_SET_INFORMATION. It is required, in order to set certain information about a process, such as its priority class.

 

The process's priority class is one of the following values.

 

Value

 

Priority

Description

32

NORMAL_PRIORITY_CLASS

Indicates a normal process with no special scheduling needs.

 

64

IDLE_PRIORITY_CLASS

Indicates a process whose threads run only when the system is idle and are preempted by the threads of any process running in a higher priority class. An example is a screen saver. The idle priority class is inherited by child processes.

 

128

HIGH_PRIORITY_CLASS

Indicates a process that performs time-critical tasks that must be executed immediately for it to run correctly. The threads of a high-priority class process preempt the threads of normal or idle priority class processes. An example is the Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when using the high-priority class, because a high-priority class CPU-bound application can use nearly all available cycles.

 

256

REALTIME_PRIORITY_CLASS

Indicates a process that has the highest possible priority. The threads of a real-time priority class process preempt the threads of all other processes, including operating system processes performing important tasks. For example, a real-time process that executes for more than a very brief interval can cause disk caches not to flush or cause the mouse to be unresponsive.

 

16384

BELOW_NORMAL_PRIORITY_CLASS

Windows NT and Windows Me/98/95: This value is not supported.

 

Indicates a process that has priority above IDLE_PRIORITY_CLASS but below NORMAL_PRIORITY_CLASS.

32768

ABOVE_NORMAL_PRIORITY_CLASS

Windows NT and Windows Me/98/95: This value is not supported.

 

Indicates a process that has priority above NORMAL_PRIORITY_CLASS but below HIGH_PRIORITY_CLASS.

 

 

Example:

AddExtender("WWPRC44I.DLL",0,"WWPRC64I.DLL")
Processlist=tListProc()
lookfor="notepad"
ptr=StrIndexNC(processlist,lookfor,0,@FWDSCAN)
If ptr==0
   Message(lookfor,"Not found")
   Exit
EndIf
ptr=StrIndex(processlist,"|",ptr,@FWDSCAN)
ptr2=StrIndex(processlist,@TAB,ptr,@FWDSCAN)
If ptr2==0;if last item in list
   pid=StrSub(processlist,ptr+1,-1)
Else
   pid=StrSub(processlist,ptr+1,ptr2-ptr-1)
EndIf
Message(lookfor,pid)
ret = tSetPriority(pid,128);set to high priority
Message("Check priority of 'notepad' process in Task Manager","It should be set to high")
ret = tSetPriority(pid,32);set back to normal
Message("Check priority of 'notepad' process in Task Manager","It should be set back to normal")
See Also:

tGetPriority