[Lazarus] How to cast a Interface to a Object in Lazaeus

Michael Van Canneyt michael at freepascal.org
Fri Mar 13 11:04:21 CET 2015



On Fri, 13 Mar 2015, aradeonas wrote:

> OK,So in the end how can I cast a Interface to a Object in Lazarus?

You can not. You are not even supposed to be able to do that.

You can only query other interfaces from an existing interface.

See my first mail: define N interfaces. When you receive an IFile interface from somewhere,
query it for the other interfaces:

Var
   MyFile : IFile;
   MyVideo : IVideo;


begin
   MyFile:=MyFileList[i];
   if MyFile.QueryInterface(IVideo,MyVideo)=0 then
     begin
     // MyVideo now holds a IVideo interface.
     end;
end;


Michael.




More information about the Lazarus mailing list