유돌이

calendar

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

Notice

2019. 10. 2. 11:38 델파이

procedure SetHighPriority(ProcName: String);
var
  Process32: TProcessEntry32;
  H: THandle;
  Next: Boolean;
  pID: DWORD;


begin
  Process32.dwSize:=SizeOf(Process32);
  H:=CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);

 

  if Process32First(H, Process32) then begin
    repeat
      Next:=Process32Next(H, Process32);
      if Process32.szExeFile=ProcName then begin
        pID:=OpenProcess(PROCESS_ALL_ACCESS, False, Process32.th32ProcessID);
        if pID<>0 then begin
          ShowMessage('Success: '+ProcName);
          SetPriorityClass(pID, HIGH_PRIORITY_CLASS);
        end
        else ShowMessage('Error : OpenProcess');
      end;
    until not Next;
  end;

 

  CloseHandle(pID);

  CloseHandle(H);
end;

posted by 유돌이