Summary

Because objects in OLE are accessed exclusively through interface pointers, a client needs ways to access an object's data. One such way is through the interface IDataObject, which exposes an object's structured information. Any object that implements this interface is called a data object.

Data exchange through IDataObject works with two structures named FORMATETC and STGMEDIUM. The FORMATETC structure improves on the idea of a clipboard format by adding an aspect (content, icon, thumbnail, and so on), a device description, and a transfer medium indicator. The STGMEDIUM structure improves on a global-memory handle, allowing data exchange to occur in a variety of mediums such as memory, storage elements, stream elements, and disk files. Through these structures, a data object and a data consumer can exchange rich data in a very efficient manner.

The IDataObject interface itself incorporates the best of all existing transfer protocols in Windows, such as the clipboard and DDE. Through its member functions, a client of a data object can get or set data, query and enumerate formats, get data in a preallocated medium, check format equivalency, and manage a notification loop with the data object. That all of this functionality is centrally located in one interface makes data transfer through the interface a uniform operation regardless of how a pointer to that interface is communicated between a data source and its consumer. This is where the name "Uniform Data Transfer" comes from.

Enumerating formats involves an enumerator for the FORMATETC structure that implements IEnumFORMATETC. OLE provides a standard implementation of such an enumerator that uses an object's registry entries to find the list of formats. A notification loop with a data object involves an interface named IAdviseSink, specifically its member OnDataChange. Through this asynchronous call, a client can know when data changes occur in any number of sources. OLE also provides a service for data objects that manages multiple sinks and sends notifications to them.

OLE's Uniform Data Transfer is a new, very flexible standard that will find broad application in many areas. It can also supplant Dynamic Data Exchange (DDE), although the two exchange mechanisms are slightly different. This chapter examines a situation in which an industry group for real-time market data replaced a DDE-based solution with an OLE-based solution, showing the flexibility of this OLE technology.

In this chapter, we also examine the considerations and issues surrounding the implementation of data objects in both in-process and local servers. We also take a look at a data consumer (a client) that also works with data change notifications.