Contents Index Topic Contents | ||
Previous Topic: IBindHost::MonikerBindToStorage Next Topic: IServiceProvider::QueryService |
The IServiceProvider Interface
IServiceProvider is a generic access mechanism to locate a GUID-identified "service" that is provided through a control or any other objects that it can communicate with. For example, an embedded object (such as an OLE control) normally only communicates with its associated "client site" object in the container through the IOleClientSite interface supplied through IOleObject::SetClientSite. Such an embedded object is required to ask the client site for some other service that the container supports when that service may not necessarily be implemented in the site itself.
In this regard, the site must provide a means through which the control managed by that site can access the service when necessary. A specific example of this necessity can be found in the function IOleInPlaceSite::GetWindowContext, through which an in-place object or control can access interface pointers for the document object that contains the site and the frame object that contains the document. Because these interface pointers exists on separate objects, the control cannot call the site's QueryInterface to obtain those pointers.
The generic architecture for achieving the same ends, without requiring ad hoc solutions where the need arises, is the interface IServiceProvider whose existence says "somewhere in the code of which I'm part exists some set of services that can be accessed through this interface."
The interface itself has only one member, QueryService, through which a caller specifies the service ID (SID, a GUID), the IID of the interface desired in return, and the address of the caller's interface pointer variable.
IDL:
[ uuid(6d5140c1-7436-11ce-8034-00aa006009fa) , object,pointer_default(unique) ] interface IServiceProvider : IUnknown { HRESULT QueryService([in] REFGUID guidService , [in] REFIID riid, [out, iid_is(riid)] void **ppv); }IServiceProvider::QueryService
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.