5.2 How Client and Server Applications Communicate

As shown in Figure 29, communication between a client application, a server application, an optional object handler, and the two OLE libraries, OLECLI.DLL and OLESVR.DLL, takes place on several different levels:

The client application calls API functions in OLECLI.DLL.

OLECLI.DLL sends notifications to the client through the CallBack function.

If an object handler exists, the client DLL may call the object handler's exported functions to perform various operations for an object, eliminating the need to start the server application. See chapter 6, "Implementing Object Handlers."

Figure 29. OLE communication paths

OLECLI.DLL and OLESVR.DLL communicate through DDE messages.

OLESVR.DLL calls the server application's exported callback functions to request various actions in the server application or to make changes in the document or object.

The server application calls API functions in OLESVR.DLL.

An OLE client application in this model makes API function calls to OLECLI.DLL and the DLL calls the CallBack function in the client application to notify it of changes. For example, when the server application changes a linked object it sends an OLE_CHANGED notification that eventually ends up in the client's CallBack function. In response to this notification, the client application repaints the object by calling the OleDraw function in OLECLI.DLL.

Note Although OLECLI.DLL uses DDE messages to communicate with OLESVR.DLL, a client application should not depend on this fact. Future versions of the OLE libraries may not necessarily use the DDE mechanism. The OLE libraries hide the underlying mechanism beneath a set of function calls and allow the mechanism to change and improve without requiring changes to the application.