Originally posted by rbutcher
JCare to share the source so I can see how it's done ?
Here is the relevant piece of code:
Code:
HANDLE hProcessSnap = NULL;
BOOL bRet = FALSE;
THREADENTRY32 te32 = {0};
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
return (FALSE);
// Fill in the size of the structure before using it.
te32.dwSize = sizeof(THREADENTRY32);
// Get first process information
Thread32First(hProcessSnap, &te32)
// get the thread priority
HANDLE hThread;
hThread = OpenThread(THREAD_SET_INFORMATION|THREAD_QUERY_INFORMATION, FALSE, te32.th32ThreadID);
// set new priority class
if (SetThreadPriority(hThread, threadPriority) != TRUE)
{
cerr << "SetThreadPriority() ";
printError();
}
CloseHandle(hThread);