Create high priority process

I have an application which starts a bunch of other processes. I need one of these processes to be "high-priority" as it is a real-time application (though it's not an embedded machine so I don't want to use real-time priority).

1
2
CreateProcess("MyProcess.exe", NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, 
        "C:\SomeDir\", &My_StartupInfo, &My_ProcessInfo); 


When I check this process in TaskManager or ProcessExplorer, I see that it is running in NORMAL_PRIORITY_CLASS. Where can I look for this?
closed account (G309216C)
Use SetThreadPriortiy() function. MSDN documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686277(v=vs.85).aspx

Good Luck!
This works for me:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#define USING_WIN32_LEAN_AND_MEAN
#include <windows.h>


int main ()
{

    STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);

PROCESS_INFORMATION processInformation;

// Try to start the process
BOOL result = CreateProcessA(
  "C:\\Windows\\NOTEPAD.exe",
  NULL,
  NULL,
  NULL,
  FALSE,
  HIGH_PRIORITY_CLASS,
  NULL,
  NULL,
  &startupInfo,
  &processInformation
);
}
And for me, too.

I stole mordoran's code and tried it as-is, with notepad (with HIGH_PRIORITY_CLASS), and also with a console app (with HIGH_PRIORITY_CLASS | CREATE_NEW_CONSOLE, on the off chance that it would make an unexpected difference. It didn't.) Both ran at high priority.

I was using Windows 7 for the test.

Andy
Thanks guys,

I'm working on a Windows Server 2003 device, so maybe that is the difference. I've also found that the scheduler that I'm using may be over-writing the priorities that I am trying to establish once it's already started.
I repeated the little test on a Windows XP SP3 desktop PC, and both cases ran at high priority.

Andy
Topic archived. No new replies allowed.