Process priority class |
Thread priority level |
Base priority |
|
---|---|---|---|
IDLE_PRIORITY_CLASS |
THREAD_PRIORITY_IDLE |
1 |
|
THREAD_PRIORITY_LOWEST |
2 |
||
THREAD_PRIORITY_BELOW_NORMAL |
3 |
||
THREAD_PRIORITY_NORMAL |
4 |
||
THREAD_PRIORITY_ABOVE_NORMAL |
5 |
||
THREAD_PRIORITY_HIGHEST |
6 |
||
THREAD_PRIORITY_TIME_CRITICAL |
15 |
||
BELOW_NORMAL_PRIORITY_CLASS |
THREAD_PRIORITY_IDLE |
1 |
|
THREAD_PRIORITY_LOWEST |
4 |
||
THREAD_PRIORITY_BELOW_NORMAL |
5 |
||
THREAD_PRIORITY_NORMAL |
6 |
||
THREAD_PRIORITY_ABOVE_NORMAL |
7 |
||
THREAD_PRIORITY_HIGHEST |
8 |
||
THREAD_PRIORITY_TIME_CRITICAL |
15 |
||
NORMAL_PRIORITY_CLASS |
THREAD_PRIORITY_IDLE |
1 |
|
THREAD_PRIORITY_LOWEST |
6 |
||
THREAD_PRIORITY_BELOW_NORMAL |
7 |
||
THREAD_PRIORITY_NORMAL |
8 |
||
THREAD_PRIORITY_ABOVE_NORMAL |
9 |
||
THREAD_PRIORITY_HIGHEST |
10 |
||
THREAD_PRIORITY_TIME_CRITICAL |
15 |
||
ABOVE_NORMAL_PRIORITY_CLASS |
THREAD_PRIORITY_IDLE |
1 |
|
THREAD_PRIORITY_LOWEST |
8 |
||
THREAD_PRIORITY_BELOW_NORMAL |
9 |
||
THREAD_PRIORITY_NORMAL |
10 |
||
THREAD_PRIORITY_ABOVE_NORMAL |
11 |
||
THREAD_PRIORITY_HIGHEST |
12 |
||
THREAD_PRIORITY_TIME_CRITICAL |
15 |
||
HIGH_PRIORITY_CLASS |
THREAD_PRIORITY_IDLE |
1 |
|
THREAD_PRIORITY_LOWEST |
11 |
||
THREAD_PRIORITY_BELOW_NORMAL |
12 |
||
THREAD_PRIORITY_NORMAL |
13 |
||
THREAD_PRIORITY_ABOVE_NORMAL |
14 |
||
THREAD_PRIORITY_HIGHEST |
15 |
||
THREAD_PRIORITY_TIME_CRITICAL |
15 |
||
REALTIME_PRIORITY_CLASS |
THREAD_PRIORITY_IDLE |
16 |
|
THREAD_PRIORITY_LOWEST |
22 |
||
THREAD_PRIORITY_BELOW_NORMAL |
23 |
||
THREAD_PRIORITY_NORMAL |
24 |
||
THREAD_PRIORITY_ABOVE_NORMAL |
25 |
||
THREAD_PRIORITY_HIGHEST |
26 |
||
THREAD_PRIORITY_TIME_CRITICAL |
31 |
//得到當前進程ID
DWORD dwProcessID = GetCurrentProcessId();
//得到當前進程句柄
HANDLE hProcess = GetCurrentProcess();
//提升進程優先級
SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS);
關於優先級的操作
在程序中,可以獲取和更改進程和線程的優先級。對於進程的優先級類有如下
函數:
DWORD GetPriorityClass(HANDLE hProcess); // hProcess爲進程句柄
BOOL SetPriorityClass(HANEL hProcess, DWORD dwPriority);
對線程的優先級有這兩個函數:
int GetThreadPriority(HANDLE hThread); //hThread爲線程句柄
BOOL SetThreadPriority(HANDLE hThread, int nPriority);