Using QueryService to expose a native object model interface for an IAccessible object

Server developers can use this technique to expose a pointer to a custom document node for an IAccessible object. This assumes that you already expose IAccessible objects. This technique allows clients to get a custom object from an IAccessible object.

To expose a native object model for an IAccessible (servers)

  1. Add support for the IServiceProvider interface on your IAccessible object.
  2. Define a GUID that represents the functionality of obtaining the custom interface from an IAccessible objects. This is called a service ID. You can use GUIDGEN.EXE to generate a service ID, or reuse the interface ID if you have a custom interface.
  3. Implement the IServiceProvider::QueryService method so that it returns a pointer to the custom interface when called with the service ID defined earlier in this procedure. QueryService should return NULL for all other service ID values.
  4. Publish the service ID so that clients can use it.

Clients can use this functionality to obtain a pointer to the custom object from an IAccessible object.

To obtain a pointer to a custom object from an IAccessible (clients)

  1. Call QueryInterface( IID_IServiceProvider) on an IAccessible interface pointer to obtain an IServerProvider interface pointer.
  2. Call IServiceProvider::QueryService with the published service ID to obtain a pointer to the custom object for the IAccessible.
  3. Release the IServiceProvider interface if it is no longer needed.

To be usable across processes, servers might need to register the returned interface with COM.

For more information about QueryService, see IServiceProvider::QueryService.

This technique is currently used by Internet Explorer version 4.0 and later. It allows clients to obtain an IHTMLElement2 interface pointer that corresponds to an IAccessible object. For more information, see Active Accessibility Support.