Dynamic Data Exchange (DDE) is one of three mechanisms of interprocess communication supported under Windows. The other two are the Windows clipboard (which I discussed in Chapter 16) and shared memory in dynamic link libraries (Chapter 19).
DDE is based on the messaging system built into Windows. Two Windows programs carry on a DDE ”conversation“ by posting messages to each other. These two programs are known as the ”server“ and the ”client.“ A DDE server is the program that has access to data that may be useful to other Windows programs. A DDE client is the program that obtains this data from the server.
A DDE conversation is initiated by the client program. The client broadcasts a message (called WM_DDE_INITIATE) to all currently running Windows programs. This message indicates a general category of data the client needs. A DDE server that has this data can respond to this broadcasted message. At that point, the conversation begins.
A single Windows program can be both a client to one program and a server to another, but this requires two different DDE conversations. A server can deliver data to multiple clients, and a client can obtain data from multiple servers, but again, this requires multiple DDE conversations. To keep these conversations unique and separate, each conversation (on both the client and server sides) uses a different window. Generally, a program that supports DDE will create a hidden child window for each conversation it maintains.
The programs involved in a DDE conversation need not be specifically coded to work with each other. As I'll discuss in the next section, generally the writer of a DDE server will publicly document how the data is identified. A user of a program that can act as a DDE client (such as Microsoft Excel) can use this information to establish a DDE conversation between the two programs.
If you write a family of two or more Windows programs that must communicate with each other but not with other Windows programs, you may consider defining your own messaging protocol. However, this is not recommended. While it may work in Windows 3, it is possible that future versions of Windows will not support any form of message-based interprocess communication except for DDE.
Because DDE uses the messaging system built into Windows, it fits very naturally in the environment. But this is not to say that DDE is easy to implement. The protocol has many options, and programs must be ready to deal with some rather tricky problems.