RAD Studio VCL Reference
TObject::GetInterface Method

Retrieves a specified interface.

function GetInterface(const IID: TGUID; out Obj): Boolean;
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) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!