Главная страница | назад





Article #16898: Alloting CPU time

 Question and Answer Database
FAQ1898D.txt Alloting CPU time
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How can I change the amount of CPU time that is alotted to my
application?
Answer:
The following example demonstrates changing the CPU priority given
an application. Care should be taken when changing the applications
priority, as values that are too high may cause the system to become
unresponsive. For more information, please see the Win32 help
file for the SetThreadPriority() function.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
ProcessID : DWORD;
ProcessHandle : THandle;
ThreadHandle : THandle;
begin
ProcessID := GetCurrentProcessID;
ProcessHandle := OpenProcess(PROCESS_SET_INFORMATION,
false,
ProcessID);
SetPriorityClass(ProcessHandle, REALTIME_PRIORITY_CLASS);
ThreadHandle := GetCurrentThread;
SetThreadPriority(ThreadHandle, THREAD_PRIORITY_TIME_CRITICAL);
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99