I've tried demoting a thread priority from realtime to something lower in VB and C++. Neither worked. Thus, I am curious as to if it is possible to force a thread of another program to go to a lower priority using assembly, if the ThreadID is known. Any help would be appreciated!

I'm using WinME (and no, I don't have the option of using another OS).
Posted on 2002-03-31 15:57:03 by VictorB212
here is the API (in fact, you *can* do it from C!)

BOOL SetThreadPriority(
HANDLE hThread, // handle to the thread
int nPriority // thread priority level

but you have to pass a handle to the thread. use the following API call:

HANDLE OpenThread(
DWORD dwDesiredAccess, // access right
BOOL bInheritHandle, // handle inheritance option
DWORD dwThreadId // thread identifier

hope that helps, VictorB212!
Posted on 2002-03-31 16:36:24 by jademtech
Just a note about OpenThread:

Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows Me.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

It will work for you but keep in mind that it won't work on win9x and NT 4.

Posted on 2002-03-31 16:40:29 by Thomas
Unfortunately, OpenHandle is not declared in the Winbase.h that comes with winME (undeclared identifier).

I realized that SetThreadPriority didn't work because I hadn't used OpenHandle. However, I cannot use that function in c++, thought I CAN use it in VB, but SetThreadPriority still doesn't work in VB. Therefore, is there a c++ or assembly procedure that WILL work in winME?
Posted on 2002-03-31 17:52:51 by VictorB212

Iczelion has all kinds of cool things on his site. on the above page is a prog called AsmTask that comes with source. it is supposed to let you change the priority of a thread
Posted on 2002-03-31 21:35:34 by dionysus

DWORD dwDesiredAccess,
BOOL bInheritHandle,
DWORD dwThreadId


You might need a newer version of your includes and kernel32.lib. If you have a fast inernet conneciton, download the platform SDK, all the necessary files are in there. If not, you could try GetModuleHandle("kernel32.dll")/GetProcAddress(handle,"OpenThread").

Posted on 2002-04-01 03:22:15 by Thomas