全部博文(788)
分类:
2009-04-08 09:22:44
太多例程了,我提供一个老外的:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function KeyBoardProc(code:integer;wparam:wparam;lparam:lparam):lresult;
var
Form1: TForm1;
Hook:HHOOK;
implementation
{$R *.dfm}
function KeyBoardProc(code:integer;wparam:wparam;lparam:lparam):lresult;
begin
result:=0; //0:表示截获后不处理键盘消息 1:表示截获后屏蔽键盘消息
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Hook:=SetWindowsHookEx(WH_KEYBOARD,@KeyBoardProc,hInstance,0);
end;