in reply to Re^10: how to change process & thread priority on Win32 ?
in thread how to change process & thread priority on Win32 ?
Take a look at the prototype for OpenThread():
HANDLE OpenThread( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId );
The only parameter there for identifying the thread to open, is the dwThreadId. Remember I described ThreadId as process unique--not system unique. Basically, OpenThread() can only be used to obtain handles to threads within the process from which it is called.
To be able to do this across process boundaries, it would need to also take a PID, so that you could ask it to give you a handle to 'this thread', within 'this process'. Without that, it will always attempt to get a handle to the specified TID within the current process.
As I said, I am not aware of any API for obtaining a thread handle to a thread in another process.
You could try the CreateRemoteThread() API to inject a thread into the process you trying to alter, and run the CreateSnapshot/OpenThread/SetThreadPriority from there, but from experience, the first of those is not an easy API to make work. Even if you get that going, I am not sure that it would allow a thread created by another process to mess with priorities.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^12: how to change process & thread priority on Win32 ?
by rbutcher (Beadle) on Dec 12, 2005 at 09:47 UTC | |
by BrowserUk (Patriarch) on Dec 12, 2005 at 23:38 UTC | |
by rbutcher (Beadle) on Dec 13, 2005 at 05:26 UTC | |
by BrowserUk (Patriarch) on Dec 13, 2005 at 05:48 UTC | |
by rbutcher (Beadle) on Dec 16, 2005 at 00:13 UTC | |
|