Passing an Object as an Interface

Posted by Christopher Chase on Stack Overflow See other posts from Stack Overflow or by Christopher Chase
Published on 2010-05-26T01:55:31Z Indexed on 2010/05/26 2:01 UTC
Read the original article Hit count: 317

Filed under:
|
|

This should be a simple answer, i believe its going to be a no,
but taken from a larger project, i have an interface and the procedure

iMyUnknown= interface(IInterface)
 ['..GUID..']
end;
procedure WorkObject(iObj :iMyUnknown);

i know this works

var 
  MyUnknown : iMyUnknown;
begin
 if supports(obj, iMyUnknown, MyUnknown) then
  WorkObject(MyUnknown);

But is it possible to do something like this?

if supports(obj, iMyUnknown) then
  WorkObject(obj as iMyUnknown);

© Stack Overflow or respective owner

Related posts about delphi

Related posts about interfaces