
24.01.2012, 13:32
|
Новичок
|
|
Регистрация: 28.07.2009
Сообщения: 85
Репутация: 50
|
|
Простенький пример
Код:
procedure TForm1.Timer1Timer(Sender: TObject);
var
SnapShot: THandle;
ProcessEntry32: TProcessEntry32;
ProcessHandle: THandle;
PriorityClass: DWORD;
begin
ListBox1.Items.BeginUpdate;
try
ListBox1.Items.Clear;
SnapShot := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
if SnapShot <> INVALID_HANDLE_VALUE then
begin
try
ProcessEntry32.dwSize := SizeOf(TProcessEntry32);
while Process32Next(SnapShot, ProcessEntry32) = True do
begin
PriorityClass:= 0;
ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcessEntry32.th32ProcessID);
if ProcessHandle <> 0 then
begin
try
PriorityClass:= GetPriorityClass(ProcessHandle);
finally
CloseHandle(ProcessHandle);
end;
end;
ListBox1.Items.Add(ProcessEntry32.szExeFile + ' Приоритет: ' + IntToStr(PriorityClass));
end;
finally
CloseHandle(SnapShot);
end;
end;
finally
ListBox1.Items.EndUpdate;
end;
end;
|