• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

## 5 posts in this topic

Zenroth,

SetThreadPriority accepts the HANDLE to a thread, and an integer specifying the priority level.

An HWND is not a valid parameter to the SetThreadPriority function.

If you are looking at using the handle to the thread you are currently in, try using GetCurrentThread.

HTH,

-mordell

0

##### Share on other sites
code:
HANDLE hProc=GetCurrentProcess();SetPriorityClass(hProc,REALTIME_PRIORITY_CLASS);

0

##### Share on other sites
Thanks a million Gromit i had tryed
SetPriorityClass(GetCurrentProcess,REALTIME_PRIORITY_CLASS);

But it hadnt worked guess i have to make a handle and call GetCurrentProcess(); on it. Anyways thanks alot.

0

##### Share on other sites
Be careful setting real-time priority, you may interfere with Windows background tasks (like clearing disk buffers.)

Also, you may find that this will not help much on a single-threaded app.

Typically, your application is taking 99% of the CPU time anyway. Don't count on switching your process's priority to cause a huge speedup.

0

##### Share on other sites
Please help me out here ive been looking at msdn ,and my compiler docs for 2 days now.
How do you set the handle for SetThreadPriority()
Ive tried using my hwnd,ive tried
well about 5 differnt ways. I just want to increase my main process priority.
0

##### Share on other sites
Just to be clear, since I see both here, there are two separate (but intertwined) ways to change priority. SetPriorityClass() and SetThreadPriority(). Class sets the base priority, and thread changes it relative to the Class. There is a list in the MS help somewhere of how the different combinations add up relative to other combinations. But it is not a good idea to use the realtime priorities. Use HIGH and HIGHEST. It avoids Window's sometimes butting in, but allows it to do any mandatory stuff it needs to.

Rock

0