RTTI not returning function in getMethods

Asked

Viewed 88 times

0

I have the following class

   TClasse = class
   public
      Funcao: function(arg: String): Integer; stdcall;
   end;

What happens is that when using RTTI in this class to return the "Function" function, it does not back because it is set to "nil", there is some way to return this function?

RTTI code:

   function GetFunctionName(FuncPointer: Pointer):PAnsiChar;
   type
      PIInterface = ^IInterface;
   var
      obj: TObject;
      Ctx: TRttiContext;
      RttiType: TRttitype;
      Method: TRttiMethod;
   begin

      obj := PIInterface(@FuncPointer)^ as TInterfacedObject;
      RttiType := Ctx.GetType(obj.ClassType);
      for method in RttiType.GetMethods do
      begin
         if method.CodeAddress = funcPointer then
            result := PAnsiChar(method.name);
      end;
   end;
  • You can post the code (RTTI) that you are using to extract class functions?

  • @Andrey just updated

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.