Hi! I was wondering if there was a way to change a process's priority in order to increase one game's FPS or just to make a certain program going faster... I see that some applications are able to determine (like Windows's Task Manager) process priority, but in C++ is it possible to write code for this?
Yes, programs can change their own priority, though it's highly not recommended unless you're decreasing it priority. Search the MSDN library for the appropriate Windows function that changes the priority of an application. I don't know what it is and I've never seen it in code, I have however seen programs offer the option to set it's priority.
I would perhaps suggest you let the user of your program decide. Messing with a process priority is not to be taken lightly since it may (and often will) affect the performance of other more critical processes.
Also increasing the priority of a process is not a guarantee the app will run faster. It is simply a guarantee any resources will be lent to it before they are to other processes of a lower priority. This may or may not increase the performance.
The solution for your problem, as I see it, is good quality code.
The users themselves decide what they want to do with your app. Starting it from a batch file with "start /HIGH appname.exe" is good enough. Or simply using the control panel to increase the priority. It's their computer, their resources, their decision.
Unless of course we are talking of some system critical application you are developing.
EDIT: Which is definitely not the case in a game forum.
Didn't even know that "start /HIGH appname.exe" was something possible to do...
Well then I will let them choose, but I still am interested in playing around with this,
so I got to msdn2 lib site and I found I had 2 functions for doing this, though these must have handles as parameters, and I don't really know how I can get to "catch" the handles of my application... What I know is this:
SetThreadPriority(): needs a handle param. to the application
SetPriorityClass(): needs a handle to a thread
So I will continue looking for how to do "handle" variables, because this typedef seems
rather confusing to me right now...
A handle is basically a reference to anything Microsoft-ish... Like windows, buttons, colours, fonts, error message returns, etc...
So, you shouldn't create them yourselves, but have them handed to you by window creating functions and so forth.
Please note that if you want to increase a process's priority, your program will need root permissions. I'm not completely sure, but I'm pretty sure that Windows programs run as root by default, however, if you were to write it for Linux or Mac, the program would look very suspicous asking for the root password to run.
Yeah, if someone is serious about playing your FPS, then they'll probably quit all the other programs. Especially if your game is good. :)