unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
Private
{ Private declarations }
public
constructor Create(AOwner: TComponent); override;
{ Public declarations }
end;
var
Form1: TForm1;
libhande: THandle;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a: function: Boolean; stdcall;
begin
try
@a := GetProcAddress(libhande, 'sethook');
Label1.Caption := '钩子安装成功,按鼠标左键会发出声音';
finally
freelibrary(libhande);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
b: function: Boolean; stdcall;
begin
try
@b := GetProcAddress(libhande, 'delhook');
Label1.Caption := '钩子删除成功,按鼠标左键会发出声音';
finally
freelibrary(libhande);
end;
end;
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
Form1.Label1.Caption := '';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
try
libhande := Loadlibrary('mousechek.dll');
ShowMessage('初始化成功!!!');
except
ShowMessage('初始化失败!!!');
Exit;
end;
end;
end.
|