Is there some additional configuration needed before I can set thread priorities in a Windows service?
In my service, I have a few threads that each call the CreateProcess() function to launch an external application. I would like to adjust thread (or process) priorities to normal or lower, depending on some other factors.
The problem is that SetThreadPriority() function fails with an error 6 (invalid handle?). I’m passing in a handle obtained from PROCESS_INFORMATION::hThread (after calling the CreateProcess() of course), so I think that the handle should be valid.
I’ve also tried setting the priority on the processes using the SetPriorityClass() function, which also fails.
The service is logged on as a local user.
Maybe you don’t have the correct access rights? MSDN on SetThreadPriority says: