3 out of 3 rated this helpful - Rate this topic

IServiceProvider::QueryService Method

Acts as the factory method for any services exposed through an implementation of IServiceProvider.

Syntax


HRESULT QueryService(
    REFGUID guidService,
    REFIID riid,
    void **ppv
);

Parameters

guidService
[in] The unique identifier of the service (an SID).
riid
[in] The unique identifier of the interface that the caller wants to receive for the service.
ppv
[out] The address of the caller-allocated variable to receive the interface pointer of the service on successful return from this function. The caller becomes responsible for calling Release through this interface pointer when the service is no longer required.

Return Value

Returns one of the following values.

S_OK The service was successfully created or retrieved. The caller is responsible for calling ((IUnknown *)*ppv)->Release();.
E_OUTOFMEMORY There is insufficient memory to create the service.
E_UNEXPECTED An unknown error occurred.
E_NOINTERFACE The service exists, but the interface requested does not exist on that service.

Remarks

QueryService creates or accesses the implementation of the service identified with guidService. In ppv, it returns the address of the interface that is specified by riid.

Because there is only one member function in this interface, E_NOTIMPL is not a valid return code. If QueryService is not implemented, the interface has no reason to exist.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
E_NOTIMPL should be returned for unimplemented service Ids
E_NOTIMPL means the service is not implemented, use this error return in this case.
E_NOINTERFACE in Visual Studio
In Visual Studio, E_NOINTERFACE is also returned if the requested service (SID) is unknown or unavailable.