回调函数实例

一 编写回调函数代码

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; 

原文地址:https://www.cnblogs.com/djcsch2001/p/2035837.html