본문 바로가기

카테고리 없음

[시스템] 내 프로그램의 실행 우선순의 바꾸기

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  saved_priority_class: Integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  // 우선순위 느리게
  saved_priority_class := GetPriorityClass(GetCurrentProcessID);
  if saved_priority_class <> 0 then
    SetPriorityClass(GetCurrentProcess, IDLE_PRIORITY_CLASS);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  // 원상복구
  if saved_priority_class <> 0 then
    SetPriorityClass(GetCurrentProcess, saved_priority_class);
end;

end.