RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TObject::GetInterface Method

Retrieves a specified interface.

Pascal
function GetInterface(const IID: TGUID; out Obj): Boolean;
C++
Boolean GetInterface(const TGUID IID, out  Obj);

System::TObject::GetInterface retrieves the interface designated by a GUID or type name. The basic implementation of System::TObject::GetInterface uses the GUID specified in the IID parameter. If the specified interface is supported by the class, it is returned in the Obj parameter, and System::TObject::GetInterface has a return value of true. Otherwise Obj contains nil (Delphi) or NULL (C++), and System::TObject::GetInterface returns false.

Note: In Delphi code, IID can be an interface name. The compiler automatically translates this name into the corresponding GUID.
Note: In C++ code, use the templated version of System::TObject::GetInterface to obtain an interface from a DelphiInterface object.
System::TObject::GetInterface is equivalent to the as operator (Delphi) and dynamic casts (C++), except that System::TObject::GetInterface does not raise an exception if the interface is not supported. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!