<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 13, 2015 at 5:49 AM, aradeonas <span dir="ltr"><<a href="mailto:aradeonas@operamail.com" target="_blank">aradeonas@operamail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">OK,So in the end how can I cast a Interface to a Object in Lazarus?<br></blockquote></div><br></div><div class="gmail_extra">The syntax show here:<br><a href="http://docwiki.embarcadero.com/RADStudio/XE7/en/Interface_References#Casting_Interface_References_to_Objects">http://docwiki.embarcadero.com/RADStudio/XE7/en/Interface_References#Casting_Interface_References_to_Objects</a><br></div><div class="gmail_extra">works in FPC as well.<br><br> var<br>   LIntfRef: IInterface;<br>   LObj: TInterfacedObject;<br> begin<br>   { Create an interfaced object and extract an interface from it. }<br>   LIntfRef := TInterfacedObject.Create();<br> <br>   { Cast the interface back to the original object. }<br>   LObj := LIntfRef as TInterfacedObject;<br> end<br><br></div><div class="gmail_extra">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). <br><br>IObjectInstance: TGuid = '{D91C9AF4-3C93-420F-A303-BF5BA82BFD23}';<br><br></div><div class="gmail_extra">All pascal objects implement it, thus you don't have to specify it implicitly. <br><br></div><div class="gmail_extra">If you're not using COM interfaces, then you'll need to add getObject() method to your interface.<br></div><div class="gmail_extra"></div><div class="gmail_extra"></div><div class="gmail_extra"><br></div><div class="gmail_extra">thanks,<br></div><div class="gmail_extra">Dmitry<br></div></div>