1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, TLHelp32;
type TForm1 = class(TForm) ListView1: TListView; btnrefesh: TButton; procedure btnrefeshClick(Sender: TObject); procedure ListView1DblClick(Sender: TObject); private public end;
var Form1: TForm1; aSnapshotHandle: THandle; aProcessEntry32: TProcessEntry32;
implementation
{$R *.dfm}
procedure TForm1.btnrefeshClick(Sender: TObject); var bContinue: BOOL; NewItem: TListItem; begin ListView1.Items.Clear; aSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); aProcessEntry32.dwSize := SizeOf(aProcessEntry32); bContinue := Process32First(aSnapshotHandle, aProcessEntry32); while Integer(bContinue) <> 0 do begin NewItem := ListView1.Items.Add; NewItem.Caption := ExtractFileName(aProcessEntry32.szExeFile); NewItem.subItems.Add(IntToHex(aProcessEntry32.th32ProcessID, 4)); NewItem.subItems.Add(aProcessEntry32.szExeFile); bContinue := Process32Next(aSnapshotHandle, aProcessEntry32); end; CloseHandle(aSnapshotHandle); end;
procedure TForm1.ListView1DblClick(Sender: TObject); var Ret: BOOL; PrID: Integer; Ph: THandle; begin with ListView1 do begin if MessageDlg('Set Process to High Priority?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin PrID := StrToInt('$' + ItemFocused.SubItems[0]); Ph := OpenProcess(1, BOOL(0), PrID); SetPriorityClass(Ph,HIGH_PRIORITY_CLASS); end; end; end;
end. |