The IServiceProvider interface is a generic access mechanism to locate a GUID-identified service.
IServiceProvider Methods
QueryService Acts as the factory method for any services exposed through an implementation of IServiceProvider.
Interface Information
Implementation Custom Inherits from IUnknown Header and IDL files Servprov.h; Servprov.idl Minimum availability Internet Explorer 4.0 Minimum operating systems Windows 95, Windows NT 4.0
Remarks
The IServiceProvider interface 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. Instead, use the IServiceProvider interface.
The IServiceProvider interface 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.