set the Systempriority?

Posted By: Bastiuscha

set the Systempriority? - 01/21/14 00:56

Hi,

can i set the Systempriority in my Code? At examble: in the Task Manager, under "Processes" i can set the acknex.exe to realtime priority with (right Mouseclick on the acknex.exe). Is there a way to set the same in the Code? I write a small Console, that have to run with full power too, if the Programm is only in the Taskbar.

Another Question: run the Acknex Engine on 4 CPU Cores?

Much Thanks!
Posted By: DLively

Re: set the Systempriority? - 01/22/14 01:58

This is in the wrong thread.
Sorry I'm not much more help than that.
Posted By: rojart

Re: set the Systempriority? - 01/27/14 23:41

Originally Posted By: Bastiuscha
...Is there a way to set the same in the Code?...

Yes, check the API SetPriorityClass function.

By the way, my Acknex Engine runs on 4 cores, 8 logical processors.
Posted By: rojart

Re: set the Systempriority? - 02/02/14 06:01

Because this should be a contribution and i found in windows.h small bug, here is the working code:

Code:
#include <acknex.h>

#define REALTIME_PRIORITY_CLASS 0x100
#define HIGH_PRIORITY_CLASS 0x80
#define ABOVE_NORMAL_PRIORITY_CLASS	0x8000
#define NORMAL_PRIORITY_CLASS 0x20
#define BELOW_NORMAL_PRIORITY_CLASS	0x4000
#define IDLE_PRIORITY_CLASS 0x40

long __stdcall SetPriorityClass(long hProcess,long dwPriorityClass);
long __stdcall GetCurrentProcess(void); // Bug! windows.h has wrong syntax GetCurrentProcess(long);

API(SetPriorityClass,kernel32)
API(GetCurrentProcess,kernel32)

void Set_Priority_Class_startup()
{
	SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
}

Posted By: Bastiuscha

Re: set the Systempriority? - 02/04/14 16:36

MUCH MUCH THANKS MAN!!!
© 2024 lite-C Forums