Código: Seleccionar todo
library Project1;
uses
Windows,
Messages;
var
HookHandle: HHOOK;
function GetMsgProc (Code: integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
msg:tmsg;
begin
if Code = HC_ACTION then
begin
if TMsg (Pointer (LParam) ^).Message =wm_char then
TMsg (Pointer (LParam) ^).wParam:= 0; //
end;
Result:= CallNextHookEx (HookHandle, Code, wParam, DWORD (lParam));
end;
procedure StarHook ; export; stdcall;
begin
HookHandle:= SetWindowsHookEx (WH_GETMESSAGE, @GetMsgProc, HInstance, 0);
end ;
procedure unook;export; stdcall;
begin
UnhookWindowsHookEx(HookHandle);
HookHandle:= 0;
end;
exports
StarHook, unook;
begin
end.
Código: Seleccionar todo
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 FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
tarea: aca van las 2 llamadas a la dll
para iniciar y detener
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
starhook;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
unook;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
unook;
end;
end.
(no se si a proposito o eran errores verdaderos)