dll全局钩子
【程序编程相关:四舍五入的BUG 】// 以下使用内存映射文件共享数据来保存键盘钩子与dll句柄 【推荐阅读:clientdataset不能在线程中使】
【扩展信息:从MDF文件恢复SqlServer200】// 运行此程序:触发程序加载完dll后,对其他系统内有键盘响应事件的程序自己挂钩// 而即使触发程序死亡,dll还是会达到监控键盘响应事件自动挂钩的目的 // 直到你按下ctrl+f组合键dll才从内存中卸载. library sysinfo; uses windows; const buffer_size = 16 * 1024; const hook_mem_filename = mem_file; type tshared = record keyhook:hhook; moudle :thandle; end; pshared = ^tshared; var memfile: thandle; shared: pshared; {撤消钩子过滤函数} function uninstallhook: boolean; begin freelibrary(shared^.moudle); result := unhookwindowshookex(shared^.keyhook); unmapviewoffile(shared); closehandle(memfile); end; function keyhookproc(icode: integer; wparam: wparam; lparam: lparam): lresult; stdcall; export; const keypressmask = $80000000; begin if icode < 0 then result := callnexthookex(shared^.keyhook, ... 下一页