delphi – 如何用接口的safecall函数方法进行RTTI调用?
发布时间:2020-12-15 10:05:33 所属栏目:大数据 来源:网络整理
导读:我有这个测试计划 https://gist.github.com/real-mielofon/5002732 RttiValue := RttiMethod.Invoke(RttiInstance,[10]); 和简单的单位与界面: unit Unit163;interfacetype{$M+} ISafeIntf = interface function TestMethod(aI: integer): integer; safecal
我有这个测试计划
https://gist.github.com/real-mielofon/5002732
RttiValue := RttiMethod.Invoke(RttiInstance,[10]); 和简单的单位与界面: unit Unit163; interface type {$M+} ISafeIntf = interface function TestMethod(aI: integer): integer; safecall; end; {$M-} type TSafeClass = class(TInterfacedObject,ISafeIntf) public function TestMethod(aI: integer): integer; safecall; end; implementation function TSafeClass.TestMethod(aI: integer): integer; begin result := aI+1; // Exception !! end; end. 我有kaboom result := aI+1; 如果是程序或不是safecall,那么没关系:-( 解决方法
现在自己尝试过,看了代码,我的结论是有一个bug. RTTI单元确实尝试执行安全方法重写.它只是看起来错了.我建议您将项目作为QC报告提交,并通过使用带有HRESULT返回值的stdcall来解决问题.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |