On 14/09/2011 23:17, Marcos Douglas wrote: > > procedure Run; > var > f: TFoo; // << type is class, not interface > o: TObj; > begin > f := TFoo.Create;
This is just wrong. > BUT, if I create my TFoo without refcount should works, right? > So, I change my class: > > TFoo = class(TObject, IFoo) > private > FInfo: string; > protected > function QueryInterface(const iid : tguid;out obj) : longint;stdcall; > function _AddRef : longint;stdcall; > function _Release : longint;stdcall; > public > function GetInfo: string; > procedure SetInfo(const AValue: string); > end; On a side note: --------------- Why not simply use CORBA interfaces, then you don't need to add the IUnknown or IInterface interface method noise to your class declaration. CORBA interfaces are not reference counted. eg: unit myunit; {$mode objfpc}{$H+} {$interfaces corba} interface type IFoo = interface // NOTE: No IInterface must be specified ['{F71A4131-E0A5-48CB-B563-7BBB079D1085}'] function GetInfo: string; end; TFoo = class(TObject, IFoo) ... end; Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal