From RAD Studio API Documentation
Jump to: navigation, search


function QueryInterface(const IID: TGUID; out Obj): HResult; virtual; stdcall;


HIDESBASE virtual HRESULT __stdcall QueryInterface(const GUID &IID, /* out */ void *Obj);


Type Visibility Source Unit Parent
function public
System.Rtti TVirtualInterface


Creates a reference to the virtual interface.

A TVirtualInterface instance represents a run-time implementation of a Delphi interface. To work with a "virtual interface", you should create a specific TVirtualInterface instance and use it to obtain a "virtual interface" reference. You can do this by casting the TVirtualInterface instance to the corresponding Delphi interface or by using the QueryInterface function.

If the operation succeeded, the return value (HRESULT) is S_OK.

QueryInterface increments the reference counter associated with the TVirtualInterface instance. (When the counter value becomes 0, the TVirtualInterface instance is destroyed automatically.) You should never destroy a TVirtualInterface instance directly.

Usage Example

For Delphi:

if TVirtualInterfaceInstance.QueryInterface(ISpecificInterface, ISpecificInterfaceInstance) = S_OK then
// ...

For C++:

if (virtualInterfaceInstance->QueryInterface(__uuidof(ISpecificInterface), &specificInterfaceInstance) == S_OK)
// ...

See Also