System.TObject.GetInterface

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function GetInterface(const IID: TGUID; out Obj): Boolean;

C++

bool __fastcall GetInterface(const GUID &IID, /* out */ void *Obj);
bool __fastcall GetInterface(DelphiInterface<T>& smartIntf)

Properties

Type Visibility Source Unit Parent
function public
System.pas
systobj.h
System TObject

Description

Retrieves a specified interface.

GetInterface retrieves the interface designated by a GUID or type name. The basic implementation of 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 GetInterface has a return value of True. Otherwise, Obj contains nil (Delphi) or NULL (C++), and 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 GetInterface to obtain an interface from a DelphiInterface object.

GetInterface is equivalent to the as operator (Delphi) and dynamic casts (C++), except that GetInterface does not raise an exception if the interface is not supported.

See Also