IMultiQI::QueryMultipleInterfaces (Compact 2013)
3/26/2014
This method fills a caller-provided array of structures with pointers to multiple interfaces.
Calling this method is equivalent to issuing a series of separate QueryInterface calls except that you do not incur the overhead of a corresponding number of RPC calls.
In multithreaded applications and distributed environments, keeping RPC calls to a minimum is essential for optimal performance.
Syntax
HRESULT QueryMultipleInterfaces(
ULONG cMQIs,
MULTI_QI* pMQIs
);
Parameters
- cMQIs
[in] Pointer to the number of elements in an array of MULTI_QI structures, each of which contains the IID of a single interface.
- pMQIs
[in, out] Pointer to the first MULTI_QI structure in the array.
Return Value
- S_OK
Pointers were returned to all requested interfaces.
- S_FALSE
Pointers were returned to some, but not all, of the requested interfaces.
- E_NOINTERFACE
Pointers were returned to none of the requested interfaces.
Remarks
The QueryMultipleInterfaces method takes as input an array of MULTI_QI structures. Each structure specifies an interface IID and contains two additional blank members for receiving an interface pointer and return value.
This method obtains as many requested interface pointers as possible directly from the object proxy.
For each interface not implemented on the proxy, the method calls the server to obtain a pointer.
Upon receiving an interface pointer from the server, the method builds a corresponding interface proxy and returns its pointer along with pointers to the interfaces it already implements.
To determine whether the platform supports this interface, see Determining Supported COM APIs.
Notes to Callers
A caller should begin by querying the object proxy for the IMultiQI interface. If the object proxy returns a pointer to this interface, the caller should then create a MULTI_QI structure for each interface it wants to obtain.
Each structure should specify an interface IID and set its pItf member to NULL. Failure to set the pItf member to NULL will cause the object proxy to ignore the structure.
On return, QueryMultipleInterfaces writes the requested interface pointer and a return value into each MULTI_QI structure in the client's array. The pItf member receives the pointer; the hr member receives the return value.
If the value returned from a call to QueryMultipleInterfaces is S_OK, then pointers were returned for all requested interfaces.
If the return value is E_NOINTERFACE, then pointers were returned for none of the requested interfaces.
If the return value is S_FALSE, then pointers to one or more requested interfaces were not returned. In this event, the client should check the hr member of each MULTI_QI structure to determine which interfaces were acquired and which were not.
If a client knows ahead of time that it will be using several of an object's interfaces, it can call QueryMultipleInterfaces up front and then, later, if a QueryInterface is done for one of the interfaces already acquired through QueryMultipleInterfaces, no RPC call will be necessary.
On return, the caller should check the hr member of each MULTI_QI structure to determine which interface pointers were and were not returned.
The client is responsible for releasing each of the acquired interfaces by calling Release.
Requirements
Header |
objidl.h, |
Library |
ole32.lib, |