# IServiceProvider::QueryService

Creates or accesses the specified service and returns an interface pointer to the specified interface for the service.

HRESULT QueryService(

REFGUID guidService, | //Unique identifier for the requested service
REFIID riid, | //Unique identifier for the requested interface
void** ppv | //Indirect pointer to the interface on the service
); |

Parameter

guidService
  [in] Unique identifier for the requestedservice.
riid
  [in] Unique identifier for the requested interface on the service.
ppv
  [out] Indirect pointer to the interface on the service.

Return Values

S_OK
  The service was successfully created or retrieved.
E_OUTOFMEMORY
  There is not enough memory to create the service.
E_UNEXPECTED
  An unknown error occurred.
E_NOINTERFACE
  The service exists but the requested interface is not provided by the service.
SVC_E_UNKNOWNSERVICE
  The service identified with guidService is not recognized.

#### Note to Callers

The caller is responsible for releasing the interface pointer when it is no longer needed.

#### Note to Implementers

Because there is only one method in this interface, E_NOTIMPL is not a valid return code.