孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

一 编写回调函数代码

type

TCallBackFunction=function(s:string):integer;

CallMe(s:string):integer;


procedure TestCallBack(CllBackFunction:TCallBackFunction);far;external 'Other';


function CallMe(s:pchar):integer;

begin

CallMe :=Length(Strpas(strpas(s)));

end;


procedure Form1.Button1Click(Sender:TObject);

begin

TestCallBack(CallMe);

end;


二 Other.dll中的代码

type

TMainFunction=function(s:string):integer;

TestCallBack(MainFunc:TMainFunc);


TestCallBack(MainFunc:TMainFunction)

var

result:integer;

begin

result :=MainFunc('test');

end; 

posted on 2008-09-10 18:40  孤独的猫  阅读(194)  评论(0编辑  收藏  举报