要求安装getmessage 钩子function abc … 怎么写?
begin
showmessage('123');
end;begin
SetWindowsHookEx(WH_Getmessage, @abc, HInstance, 0); / 怎么写?
end;怎么一直循环ABC这个过程.?abc函数的参数怎么写?.请测试好

解决方案 »

  1.   


    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
        icount : integer;
        function abc(s : string): boolean;  public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}function TForm1.abc(s: string): boolean;
    begin
      if s <> 'abc' then
      begin
        showmessage(s);
        inc(icount);
        if icount < 5 then
          abc('123');
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      abc('123');
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      icount := 0
    end;end.
      

  2.   


    function abc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;SetWindowsHookEx(WH_Getmessage, @abc, HInstance, 0);
      

  3.   

    SetWindowsHookEx(WH_Getmessage, @abc, HInstance, 0);
      

  4.   

    钩子函数,见:http://www.cnblogs.com/del/category/124150.html (API 钩子相关函数)
      

  5.   

    function abc(iCode: integer; wParam: wParam; lParam: lParam): LResult; stdcall;
    begin
      showmessage('123'); 
    end;SetWindowsHookEx(WH_Getmessage, @abc, HInstance, 0); 
    abc有消息就会执行的