15
私は、このテストプログラムインターフェイスを持つhttps://gist.github.com/real-mielofon/5002732インターフェイスのsafecall関数メソッドでRTTI-callを作成するにはどうすればよいですか?
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.
をし、それが手続きであるかそうでない場合、私は
result := aI+1;
にKABOOMを持っていますsafecall、それでいいよ.--(
私は ":HRESULT; stdcall"について知っていますが、現在入手可能な唯一の解決策は、ソースからsafecallを削除することです(と私はそれをやっています)が、RTTIで作業するにはどうすれば解決できるのでしょうか? – Mielofon
私はあなたがインターフェイスの宣言を変更する必要はないと思う。 RTTIで呼び出したときに2つのパラメータを渡し、その呼び出しの戻り値としてHRESULTを読み込みます。 –
カウントパラメータを変更すると、例外の結果が返されます。 パラメータの数が一致しません。 約: RttiHResultValue:= RttiMethod.Invoke(RttiInstance、[10、RttiReturnValue]); – Mielofon