⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getpriorityclassu.pas

📁 Delphi Win32核心API参考光盘源码 本书包含了常用的Windows API函数
💻 PAS
字号:

unit GetPriorityClassU;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  Process: THandle;       // holds a handle to the process
  PriorityClass: DWORD;   // holds the priority class
begin
  {retrieve the current process handle}
  Process := Windows.GetCurrentProcess;

  {retrieve the priority class}
  PriorityClass := GetPriorityClass(Process);

  {display the priority class}
  case PriorityClass of
    NORMAL_PRIORITY_CLASS:   Edit1.Text := 'NORMAL_PRIORITY_CLASS';
    IDLE_PRIORITY_CLASS:     Edit1.Text := 'IDLE_PRIORITY_CLASS';
    HIGH_PRIORITY_CLASS:     Edit1.Text := 'HIGH_PRIORITY_CLASS';
    REALTIME_PRIORITY_CLASS: Edit1.Text := 'REALTIME_PRIORITY_CLASS';
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  {set the selected priority class}
  case RadioGroup1.ItemIndex of
    0: SetPriorityClass(Windows.GetCurrentProcess, NORMAL_PRIORITY_CLASS);
    1: SetPriorityClass(Windows.GetCurrentProcess, IDLE_PRIORITY_CLASS);
    2: SetPriorityClass(Windows.GetCurrentProcess, HIGH_PRIORITY_CLASS);
    3: SetPriorityClass(Windows.GetCurrentProcess, REALTIME_PRIORITY_CLASS);
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -