如题。
谢谢!!

解决方案 »

  1.   

    不是。
    就像 API 函数那样,可以把函数地址传递到 API 里去,然后 API 就会调用那个函数。
    就是回调函数。我想自己定义一个这样的函数。
    谢谢~~~
      

  2.   

    这样!
    function Sum(var a,b,c:Integer)Integer;
    begin
      a:=1;
      b:=2
      c:=3
    end;  
    procedure TForm1.Button1Click(Sender: TObject);
    var a,b,c,d:Integer;begin
      a:=0;
      b:=0;
      c:=0;
      d:=Sum(a,b,c);
      showmessage(intToStr(d));
    end;
      

  3.   

    What is a Callback function, and how do I create one?Relation: [ FuncType ]
    ID: [ 000111 ]  
    A call back function is a function which you write, but is called by some other 
    program or module, such as windows.  To create a callback function, you must 
    first declare a function type, the funciton itself, and implement the function.In the interface section:{ In main program interface } 
    typeTCallBackFunction = function(s: string): integer; CallMe(s: string): integer; And in the Implementation section: { In main program implementation } 
    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);
    beginTestCallBack(CallMe);end; Note that in 'Other' you would also declare a function type, and use it like this:
     
    { in library Other interface } 
    typeTMainFunction = function(s: string): integer;
    TestCallBack(MainFunc: TMainFunction); 
    { in library Other implementation } 
    TestCallBack(MainFunc: TMainFunction);
    varresult: integer;beginresult:=MainFunc('test');end;
     
     
      

  4.   

    能不能说明白一点了
    或者CODE
      

  5.   

    type
      TTest = function (a, b: Integer): Boolean;function Hello(a, b: Integer): Boolean;
    begin
      return a = b;
    end;procedure Test(a: Integer; b: Integer; Func: TTest);
    begin
      if Func(a, b) then
        ShowMessage('Equal')
      else
        ShowMessage('Not Equal')
    end;
      

  6.   

    调用方式:
       Test(1, 2, Hello);
      

  7.   

    chechy老大,你这么多专家分了,还要和我强分啊。呜呜。
    楼主该结贴了
      

  8.   

    function yourfun_name(var a: integer):integer;
    begin
     
    end;procedure formshow;
    begin
      t:= ...
      yourfun_name(t)
      showmessage(t)
    end;这里的t就是向你要求的那样可以传进去再传出来
      

  9.   

    谢谢大家!!(马上结帖~)
    那,再请问,我想导出这个有回调参数的函数呢?(DLL导出)
    给其它语言使用,比如 VB.
    谢谢~~~~~~
      

  10.   

    如果写成引用回调函数的话,最好让用户自定义,这样才有机动性,我弄过好多硬件的DLL,大都是这样做的!
      

  11.   

    不需要导出,只要重新声明一下。如果是DLL,最好修改一下:
    type
      TTest = function (a, b: Integer): Boolean; stdcall;function Hello(a, b: Integer): Boolean; stdcall;
    begin
      return a = b;
    end;To Linux2001:下次你要回答的题目跟我说一声,我不会和你抢分的。:P