DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: jeff1314
今日帖子: 9
在线用户: 0
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 cenunus (cenunus) ★☆☆☆☆ -
普通会员
2022/9/30 12:03:27
标题:
请教Rtti的问题 浏览:821
加入我的收藏
楼主: 目的是从结构体中读取函数信息,求助大家,谢谢!
//这个是只有一些函数的结构体
TMyMethods1=record
    function 时间戳(Len:Integer):Integer;
    function 自增(I,N:Integer):Integer;
    function 自减(I,N:Integer):Integer;
    function 流转Base64字符串(AStream:TMemoryStream):string;
    function 连接字符串(连接符:string;参数:array of string):string;
  end;
//这段代码没问题
var
  m:TRttiMethod;
  Item:TMenuItem;
begin
  for m in TRttiContext.Create.GetType(TypeInfo(TMyMethods1)).GetMethods do
  begin
    Item:=TMenuItem.Create(nil);
    Item.Caption:=m.Name;
    Item.OnClick:=SystemMethodsClick;
    pm2.Items.Add(Item);
  end;
end;
//这段代码有错误
var
Param:TRttiParameter;
begin
  for Param in TRttiContext.Create.GetType(TypeInfo(TMyMethods1)).AsRecord.GetMethod(函数名称).GetParameters do
  begin
    with lv1.Items.Add do
    begin
      Caption:=Param.ParamType.ToString;
      SubItems.Add('');
    end;
  end;
end;
----------------------------------------------
作者:
男 roadrunner (roadrunner) ★☆☆☆☆ -
盒子活跃会员
2022/9/30 13:48:50
1楼: 函数名称未定义
----------------------------------------------
-
作者:
男 cenunus (cenunus) ★☆☆☆☆ -
普通会员
2022/9/30 14:35:35
2楼: 汗,果然是函数名称那里错了,谢谢楼上!
----------------------------------------------
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行99.60938毫秒 RSS