Link to home
Start Free TrialLog in
Avatar of joshhsoj
joshhsoj

asked on

thread priority

how can I change the priority that my program is running at?  I can't seem to find anything like ChangeThreadPriority.  thx
Avatar of thresher_shark
thresher_shark

I think the function you want is SetThreadPriority.  Does that do what you want?
BOOL SetThreadPriority( HANDLE hThread,
 // handle to the thread
 int nPriority
 // thread priority level  );
hThread is the return value which is returned by CretateThread

nPriority can be one of these values:
THREAD_PRIORITY_ABOVE_NORMAL
 Indicates 1 point above normal priority for the priority class.
 
THREAD_PRIORITY_BELOW_NORMAL
 Indicates 1 point below normal priority for the priority class.
 
THREAD_PRIORITY_HIGHEST
 Indicates 2 points above normal priority for the priority class.
 
THREAD_PRIORITY_IDLE
 Indicates a base priority level of 1 for IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority level of 16 for REALTIME_PRIORITY_CLASS processes.
 
THREAD_PRIORITY_LOWEST
 Indicates 2 points below normal priority for the priority class.
 
THREAD_PRIORITY_NORMAL
 Indicates normal priority for the priority class.
 
THREAD_PRIORITY_TIME_CRITICAL
 Indicates a base priority level of 15 for IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority level of 31 for REALTIME_PRIORITY_CLASS processes.
 
if you want to set the process priority
you must set the proper priority when you create the process,
when the process is created, you only can change thread priority of the process.
the thread handle of process is returned when you create the process and put in the structure.
LPPROCESS_INFORMATION lpProcessInformation


Avatar of joshhsoj

ASKER

directed at wyy_cq: your answer is a good one, but to be fare, i would like to award the pts to "threshar_shark"  how do i do that?
josh - To open the question for someone else, reject the current proposed answer.  Then I can answer and you can give me a grade.  If you need any further help, please don't hesitate to ask.
ok
ASKER CERTIFIED SOLUTION
Avatar of thresher_shark
thresher_shark

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
TO : thresher_shark
my answer is not for point only.
Helping each other is the most important.


Looks like josh accepted my answer anyway, I am glad you have that philosophy wyy_cq.  An unfortunate number of people are in it just for the points (which are essentially worthless).