On Fri, Mar 13, 2015 at 5:49 AM, aradeonas <[email protected]> wrote:
> OK,So in the end how can I cast a Interface to a Object in Lazarus? > The syntax show here: http://docwiki.embarcadero.com/RADStudio/XE7/en/Interface_References#Casting_Interface_References_to_Objects works in FPC as well. var LIntfRef: IInterface; LObj: TInterfacedObject; begin { Create an interfaced object and extract an interface from it. } LIntfRef := TInterfacedObject.Create(); { Cast the interface back to the original object. } LObj := LIntfRef as TInterfacedObject; end BUT, it would only work, if you're using COM interfaces (wont work corba). It works for COM interfaces only because FPC just checks that an interface implements IObjectInstance (via COM queryinterface method). IObjectInstance: TGuid = '{D91C9AF4-3C93-420F-A303-BF5BA82BFD23}'; All pascal objects implement it, thus you don't have to specify it implicitly. If you're not using COM interfaces, then you'll need to add getObject() method to your interface. thanks, Dmitry
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
