RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TLinkedRIO.QueryInterface Method

Implements the IInterface QueryInterface method.

Pascal
function QueryInterface(const IID: TGUID; out Obj): HResult; override; stdcall;
C++
virtual __fastcall __stdcall HRESULT QueryInterface(const TGUID IID,  Obj);

QueryInterface is called through the IInterface interface to obtain an interface pointer for the interface identified by the IID parameter. In Delphi, this call is generated when an application casts TLinkedRIO to an invokable interface using the as operator. 

TLinkedRIO can only return a single type of interface pointer. The first time an application calls QueryInterface, TLinkedRIO generates an in-memory method table to support calls to the methods on the requested interface. 

IID specifies the invokable interface that the application wants to call using this TLinkedRIO instance. If the TLinkedRIO object has already been typecast to an interface, then IID must identify that interface. If the TLinkedRIO instance has not yet been typecast to an interface, then IID must be a registered invokable interface. 

Obj returns an interface pointer for the specified interface, unless TLinkedRIO was already implementing a different interface or IID identified an interface that was not registered. 

QueryInterface returns 0 (S_OK) if Obj successfully returns an interface pointer. It returns E_NOINTERFACE otherwise.

Note: In C++, a second, templatized syntax takes a variable that is a DelphiInterface wrapper for the desired interface type.
If QueryInterface successfully returns an interface pointer, it automatically increments the reference count. 

 

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