给你一个例子:
type
TCallBackFunction = function(s: string): integer;
CallMe(s: string): integer; procedure TestCallBack(CallBackFunction: TCallBackFunction); far; external 'Other';
{ Note that 'other' is a Dll containing the procedure TestCallBack }function CallMe(s: PChar): integer;
begin
{ what ever you need to do }
CallMe := 1; { What ever you need to return }
end;procedure TForm1.Button1Click(Sender: TObject);
begin
TestCallBack(CallMe);
end;type
TMainFunction = function(s: string): integer;
TestCallBack(MainFunc: TMainFunction);
{ in library Other implementation }
TestCallBack(MainFunc: TMainFunction);
var
result: integer;
begin
result:=MainFunc('test');
end;
type
TCallBackFunction = function(s: string): integer;
CallMe(s: string): integer; procedure TestCallBack(CallBackFunction: TCallBackFunction); far; external 'Other';
{ Note that 'other' is a Dll containing the procedure TestCallBack }function CallMe(s: PChar): integer;
begin
{ what ever you need to do }
CallMe := 1; { What ever you need to return }
end;procedure TForm1.Button1Click(Sender: TObject);
begin
TestCallBack(CallMe);
end;type
TMainFunction = function(s: string): integer;
TestCallBack(MainFunc: TMainFunction);
{ in library Other implementation }
TestCallBack(MainFunc: TMainFunction);
var
result: integer;
begin
result:=MainFunc('test');
end;
解决方案 »
- 如何做控件的复制、粘帖、撤销操作?
- 编译的exe放到别的机器上运行不起来是什么原因?
- TIdTcpserver如何保持多个客户端数据同步?
- ********零分求助********早上街上碰到一个求助的美女,家产都给她了.身无分文的!
- 上传文件到服务器的问题
- 并发问题,没有分但祝大家公司愉快
- 菜鸟问题!请问如何对SQL数据库操作
- 怎么解决象死机一样的问题,我用了Application.ProcessMessage还不行,?为什么看看。在线等候
- A窗体引用B窗体同时B窗体也引用A窗体这样会有问题么?
- DELPHI中TIMER控件的问题?
- WIN XP是不是和DELPHI不兼容啊。总是出现什么‘NTDLL.DLL’的错误。这是咋回事呀?
- 怎么处理两张图片之间的淡入淡出(有没有详细)?
1、回调函数由你提供,用来操作你的数据
2、回调函数主要是由别人调用。
3、它和DLL导出函数的主要区别是,DLL是别人主动调用,而回调函数是由你指定别人调用。