unit1.pas

来自「罗小平<<delphi精要>>一书源码」· PAS 代码 · 共 58 行

PAS
58
字号
unit Unit1;

interface

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

type
  TEnableHotKeyHook = function: BOOL; stdcall;
  TDisableHotKeyHook = function: BOOL; stdcall;

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var
  
  EnableHotKeyHook: TEnableHotKeyHook;
  DisableHotKeyHook: TDisableHotKeyHook;
  DllHandle: THandle;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  EnableHotKeyHook;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  DisableHotKeyHook;
end;

initialization

  DllHandle := LoadLibrary('KeyboardHOOK.dll');
  if DllHandle <> 0 then
  begin
    @EnableHotKeyHook := GetProcAddress(DllHandle,'EnableHotKeyHook');
    @DisableHotKeyHook := GetProcAddress(DllHandle,'DisableHotKeyHook');
  end;

finalization
  FreeLibrary(DllHandle);

end.

⌨️ 快捷键说明

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