Object with IDispatch via RTTI (without TLB)

Giganews Newsgroups
Subject:Object with IDispatch via RTTI (without TLB)
Posted by: Matthias Alleweldt
Date:Wed, 25 Feb 2009

Hello!

I want to expose a Delphi object via an 'IDispatch' interface without a TypeLibrary in Delphi 2009.

I found 'IObjectDispatch' in 'ObjComAuto' wich works well with properties but crash on functions (tested in Delphi 7 and 2009).

...
{$TYPEINFO ON}
TTest = class(TObject)
private
  function GetText: string;
public
  procedure Foo;
published
  property Text : string read GetText;
end;
{$TYPEINFO OFF}
...
var iTest : IDispatch;
begin
iTest := TObjectDispatch(TTest.Create);
...

Is this a bug?

My question: Is there something what I do wrong or is there a better way for my task?

Thanks in advance

Matthias

Replies