exitwinexu.pas

来自「delphi win32api编程」· PAS 代码 · 共 49 行

PAS
49
字号
unit ExitWinExU;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

const
  {an array of shutdown constants}
  ShutDownConst: array[0..3] of UINT = (EWX_LOGOFF, EWX_POWEROFF, EWX_REBOOT,
                                        EWX_SHUTDOWN);


procedure TForm1.Button1Click(Sender: TObject);
begin
  {shuts down the system according to the selection option}
  ExitWindowsEx(ShutDownConst[ComboBox1.ItemIndex], 0);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  {logs off the current user}
  ExitWindows(0, 0);
end;

end.

⌨️ 快捷键说明

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