QueryService identifies an object that supports the requested service, with the returned pointer already set to the specified interface.
It's important to keep in mind the following:
Two different services (SID_SIdaho and SID_SMontana, for example) can both specify the use of a single interface (for example, IDispatch), even though the implementation of the interface may have nothing in common between the two services. This works because the following two hypothetical calls can return different objects:
hr = QueryService (SID_SMontana, IID_IDispatch, &pDisp) hr = QueryService (SID_SIdaho, IID_IDispatch, &pDisp)
Remember that object identity is not assumed if you ask for a different service identifier.