開發開發

          軟件的生命
          隨筆 - 18, 文章 - 0, 評論 - 0, 引用 - 0
          數據加載中……

          WH_GETMESSAGE鉤子


          unit Unit1;
          interface
          uses
            Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
            Dialogs, StdCtrls;
          const
            MYMESSAGE=WM_USER+2000;
          type
            TForm1 = class(TForm)
              Button1: TButton;
              procedure Button1Click(Sender: TObject);
              procedure FormCreate(Sender: TObject);
            *******
              { Private declarations }
            public
              { Public declarations }
            end;
          var
            Form1: TForm1;
          implementation
          {$R *.dfm}
          var
            hookHandle:HHOOK;
          procedure TForm1.Button1Click(Sender: TObject);
          begin
            PostMessage(self.Handle,MYMESSAGE,0,0);
          end;
          function getMsgProc(code:integer;wParam:WPARAM;lParam:LPARAM)
            :Longint;stdcall;
          begin
             if (Code = HC_ACTION) then
              if PMsg(lParam)^.Message = MYMESSAGE then
              begin
                showMessage('已經截獲該消息');
              end;
              Result := CallNextHookEx(hookHandle, Code, WParam, Longint(@lParam));
          end;
          procedure TForm1.FormCreate(Sender: TObject);
          begin
            hookHandle:=SetWindowsHookEx(WH_GETMESSAGE,
              getMsgProc,HInstance,GetCurrentThreadId);
          end;
          end.

           

          posted on 2011-09-23 20:35 wm6run 閱讀(1866) 評論(0)  編輯  收藏

          主站蜘蛛池模板: 诏安县| 梨树县| 大丰市| 东兰县| 渝中区| 建德市| 长宁县| 建平县| 阆中市| 刚察县| 吴忠市| 古交市| 铁岭市| 通榆县| 林甸县| 临桂县| 嘉鱼县| 招远市| 北宁市| 柏乡县| 库车县| 西畴县| 禹州市| 新野县| 嵊州市| 报价| 惠东县| 丹东市| 田林县| 藁城市| 平果县| 台东市| 临海市| 汉中市| 东光县| 黄冈市| 迭部县| 达尔| 兴和县| 周口市| 富川|