为了账号安全,请及时绑定邮箱和手机立即绑定

求助,请问vc++只用process.h中的函数怎么改变线程的优先级?

求助,请问vc++只用process.h中的函数怎么改变线程的优先级?

12345678_0001 2021-08-05 18:07:35

还有,_endthread有参数么.?

查看完整描述

1 回答

?
SMILET

TA贡献1714条经验 获得超4个赞

Form MSDN
SetThreadPriority Function
Sets the priority value for the specified thread. This value, together with the priority class of the thread's process, determines the thread's base priority level.

BOOL WINAPI SetThreadPriority( __in HANDLE hThread, __in int nPriority);
ParametershThread A handle to the thread whose priority value is to be set.
The handle must have the THREAD_SET_INFORMATION access right. For more information, see Thread Security and Access Rights.
nPriority The priority value for the thread. This parameter can be one of the following values.
Priority Meaning THREAD_MODE_BACKGROUND_BEGIN0x00010000 Begin background processing mode. The system lowers the resource scheduling priorities of the thread so that it can perform background work without significantly affecting activity in the foreground.
This value can be specified only if hThread is a handle to the current thread. The function fails if the thread is already in background processing mode.
Windows Server 2003 and Windows XP/2000: This value is not supported. THREAD_MODE_BACKGROUND_END0x00020000 End background processing mode. The system restores the resource scheduling priorities of the thread as they were before the thread entered background processing mode.
This value can be specified only if hThread is a handle to the current thread. The function fails if the thread is not in background processing mode.
Windows Server 2003 and Windows XP/2000: This value is not supported. THREAD_PRIORITY_ABOVE_NORMAL1 Priority 1 point above the priority class. THREAD_PRIORITY_BELOW_NORMAL-1 Priority 1 point below the priority class. THREAD_PRIORITY_HIGHEST2 Priority 2 points above the priority class. THREAD_PRIORITY_IDLE-15 Base priority of 1 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority of 16 for REALTIME_PRIORITY_CLASS processes. THREAD_PRIORITY_LOWEST-2 Priority 2 points below the priority class. THREAD_PRIORITY_NORMAL0 Normal priority for the priority class. THREAD_PRIORITY_TIME_CRITICAL15 Base priority of 15 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority of 31 for REALTIME_PRIORITY_CLASS processes.



查看完整回答
反对 回复 2021-08-09
  • 1 回答
  • 0 关注
  • 47 浏览
我要回答

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信