unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
const
  BELOW_NORMAL_PRIORITY_CLASS=Integer($4000);
  ABOVE_NORMAL_PRIORITY_CLASS=Integer($8000);
var Priorytet :Integer;
begin
case ListBox1.ItemIndex of
  0: Priorytet:=IDLE_PRIORITY_CLASS;
  1: Priorytet:=BELOW_NORMAL_PRIORITY_CLASS;
  2: Priorytet:=NORMAL_PRIORITY_CLASS;
  3: Priorytet:=ABOVE_NORMAL_PRIORITY_CLASS;
  4: Priorytet:=HIGH_PRIORITY_CLASS;
  5: Priorytet:=REALTIME_PRIORITY_CLASS;
  else Priorytet:=NORMAL_PRIORITY_CLASS;
  end;

SetPriorityClass(GetCurrentProcess(),Priorytet)
end;

procedure TForm1.Button2Click(Sender: TObject);
const
  BELOW_NORMAL_PRIORITY_CLASS=Integer($4000);
  ABOVE_NORMAL_PRIORITY_CLASS=Integer($8000);
var Priorytet :Integer;
begin
Priorytet:=GetPriorityClass(GetCurrentProcess());

case Priorytet of
  IDLE_PRIORITY_CLASS: ListBox1.ItemIndex:=0;
  BELOW_NORMAL_PRIORITY_CLASS: ListBox1.ItemIndex:=1;
  NORMAL_PRIORITY_CLASS: ListBox1.ItemIndex:=2;
  ABOVE_NORMAL_PRIORITY_CLASS: ListBox1.ItemIndex:=3;
  HIGH_PRIORITY_CLASS: ListBox1.ItemIndex:=4;
  REALTIME_PRIORITY_CLASS: ListBox1.ItemIndex:=5;
  else ShowMessage('Nie rozpoznana wartość priorytetu');
  end;

//ShowMessage('Priorytet: '+ListBox1.Items[ListBox1.ItemIndex]+' ('+IntToStr(Priorytet)+')');
end;

end.
