Services are groups of related interfaces. Typically, a service is defined for actions that are performed by a site. The service itself is defined by the site, but the interfaces that make up the service may be implemented by other objects on the site.
The service architecture provides a flexible, general means of making features accessible to contained objects. The flexibility comes from several important aspects of the design:
The following figure shows a hypothetical service implementation.
The figure shows four interfaces. The IServiceProvider interface provides access to services. All sites that support services implement this interface. ActiveX designers and other contained objects call the QueryService method of IServiceProvider to get pointers to the interfaces they want to use.
The other three interfaces illustrate hypothetical service implementations. The table shows the various combinations of services that can be defined. Each service has a unique service identifier (SID), similar to an interface identifier (IID). The SID is a globally unique identifier (GUID) that identifies the service in calls to QueryService.
| Service and Interface Identifiers |
|
Montana service | SID_SMontana | Provides access to the Montana interfaces. |
IID_IMontana | Montana interface. | |
Washington service | SID_SWashington | Provides access to the Washington interfaces. |
IID_IWashington | Original Washington interface. | |
Washington2 service | SID_SWashington2 | Second version of the Washington service. |
IID_IWashington | Original Washington interface. Same as IID_IWashington in SID_SWashington. | |
IID_IWashington2 | Second version of the Washington interface, with different features. |
In the figure, the Montana service is implemented on the site object, and the two Washington services are implemented on a separate object. The following configurations are also possible:
Because the IWashington interface is the same in both SWashington and SWashington2, both of these services can be implemented on the same object.
This design allows ActiveX designers and other embedded objects straightforward access to useful features of their containers. The container, in turn, can configure these features efficiently. All configurations are transparent to the ActiveX designer, and different containers may organize the services differently.