IServiceProvider
[New
- Windows NT]
The IServiceProvider
interface locates a service specified by its GUID and returns the interface
pointer for the requested interface on the service.
When to Implement
An object
that provides services should implement the IServiceProvider interface
as a general way to supply its clients with interface pointers to the
interfaces on the service.
A service is
often provided through a separate object from the client site. For example, the
service can be provided through a separate control or some other object that
the client can communicate with.
Usually, the
client communicates through its client site object in the container. The
container calls IOleObject::SetClientSite to provide a pointer to the IOleClientSite
interface for the embedded object s
client site. Then, the client must call methods in the IOleClientSite
interface to find out about services that its container supports. Thus, the
client site must provide a way for the client to access the service when
necessary, even if the service is provided through a separate object.
For example,
an in-place object calls IOleInPlaceSite::GetWindowContext to obtain
interface pointers for the document object that contains the site and for the
frame object that contains the document. Both of these interface pointers are
on objects separate from the site object, so the client cannot call IOleInPlaceSite::QueryInterface
to obtain these interface pointers.
The IServiceProvider
interface is a general way to provide interface pointers for services, so that
the site object need not implement ad hoc solutions as the need arises.
When to Use
This
interface itself has only one method, IServiceProvider::QueryService.
The caller specifies a GUID for the service and the IID of the requested
interface. The interface pointer is returned in a caller-supplied variable.
Methods in Vtable Order
IUnknown Methods |
Description |
QueryInterface |
Returns
pointers to supported interfaces. |
AddRef |
Increments
reference count. |
Release |
Decrements
reference count. |
IServiceProvider Methods |
Description |
QueryService |
Returns an
interface pointer to the requested interface on a service. |
See Also