How to set run priority?

Just starting out? Need help? Post your questions and find answers here.
Max
User
User
Posts: 67
Joined: Thu Nov 30, 2006 4:57 pm
Location: I long for the absolute loneliness of the death

How to set run priority?

Post by Max »

Hi,
Someone knows how to set run priority for a process launched by PB?

Run priority has 6 levels:
Real Time: 24
High: 13
Above Normal:10
Normal:8
Below Normal:6
Idle:4

How to change the process among them?
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: How to set run priority?

Post by traumatic »

Code: Select all

SetPriorityClass_(hProcess.l, dwPriorityClass.l)
So, to set your app's priority class to realtime for example:

Code: Select all

SetPriorityClass_(GetCurrentProcess_(), #REALTIME_PRIORITY_CLASS) 

However I'm not sure if that's what you meant.
Good programmers don't comment their code. It was hard to write, should be hard to read.
Max
User
User
Posts: 67
Joined: Thu Nov 30, 2006 4:57 pm
Location: I long for the absolute loneliness of the death

Post by Max »

YES. I will try it.

Thx traumatic
TheCorporation
User
User
Posts: 11
Joined: Fri Sep 15, 2006 8:04 am
Location: FR

Re: How to set run priority?

Post by TheCorporation »

SetPriorityClass don't seem to exist under Pure Basic :-(

Max could you give me your test result ?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

SetPriorityClass don't seem to exist under Pure Basic
If you are using the demo version of PureBasic, the API calls aren't available directly, which could be why you're not finding it. If that's the case, you can do it another way:

Code: Select all

#HIGH_PRIORITY_CLASS = $80
OpenLibrary(0, "kernel32.dll")
process = CallFunction(0, "GetCurrentProcess")
CallFunction(0, "SetPriorityClass", process, #HIGH_PRIORITY_CLASS)
CloseLibrary(0)
BERESHEIT
Post Reply