试试if @a = @func1 then...

解决方案 »

  1.   

    if (@a) = (@TYourClass.Func1) then begin
    end;
      

  2.   

    我试过了,xzgyb的方法可以。
      

  3.   

    事实上,Delphi帮助就有var
      F, G: function: Integer;
      I: Integer;
    function SomeFunction: Integer;
     ...
    F := SomeFunction;  // assign SomeFunction to F
    G := F;             // copy F to G
    I := G;             // call function; assign result to IThe first statement assigns a procedural value to F. The second statement copies that value to another variable. The third statement makes a call to the referenced function and assigns the result to I. Because I is an integer variable, not a procedural one, the last assignment actually calls the function (which returns an integer).
    In some situations it is less clear how a procedural variable should be interpreted. Consider the statementif F = MyFunction then ...;In this case, the occurrence of F results in a function call; the compiler calls the function pointed to by F, then calls the function MyFunction, then compares the results. The rule is that whenever a procedural variable occurs within an expression, it represents a call to the referenced procedure or function. In a case where F references a procedure (which doesn抰 return a value), or where F references a function that requires parameters, the statement above causes a compilation error. To compare the procedural value of F with MyFunction, useif @F = @MyFunction then ...;@F converts F into an untyped pointer variable that contains an address, and @MyFunction returns the address of MyFunction.
    To get the memory address of a procedural variable (rather than the address stored in it), use @@
    . For example, @@F returns the address of F.