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);