program highapp; {$R *.res} uses tlhelp32,windows,sysutils; type ProcessEntry32_ARRAY = Array of TProcessEntry32; Function GetAllProcesses : ProcessEntry32_ARRAY; var bFound : Boolean; SnapshotHandle : THandle; ProcessEntry32 : TProcessEntry32; begin SnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); ProcessEntry32.dwSize := Sizeof(ProcessEntry32); bFound := Process32First(SnapshotHandle,ProcessEntry32); while bFound do begin SetLength(Result, Length(Result)+1); Result[Length(Result)-1] := ProcessEntry32; bFound := Process32Next(SnapshotHandle,ProcessEntry32); end; CloseHandle(SnapshotHandle); end; var aProcess : ProcessEntry32_ARRAY; i:integer; han:Thandle; pri:integer; lnch:string; begin aProcess := GetAllProcesses; pri:=strtointdef(paramstr(1),-1); if pri=-1 then begin pri:=2; lnch:=paramstr(1); end else lnch:=paramstr(2); case pri of 0:pri:=IDLE_PRIORITY_CLASS; 1:pri:=NORMAL_PRIORITY_CLASS; 2:pri:=HIGH_PRIORITY_CLASS; else pri:=REALTIME_PRIORITY_CLASS; end; for i:=0 to Length(aProcess)-1 do begin if ansistrIcomp(aProcess[i].szExeFile,pchar(lnch))=0 then begin han:=OpenProcess(PROCESS_SET_INFORMATION,True,aprocess[i].th32ProcessID); setpriorityclass(han,pri); closehandle(han); end; end; end.