DDE Overview

DDE (Dynamic Data Exchange) is a well-established mechanism for exchanging data among processes in MS-Windows. The mechanism was intentionally designed to be easy to use and to represent data as simply as possible. DDE is implemented in many popular programs that run in Windows, such as Microsoft Excel and Microsoft Word. This widespread availability makes DDE a good choice for general data sharing.

The competition with DDE is COM, with its variants for OLE: OPC and ActiveX. By comparison, DDE is simpler, and therefore faster, than the equivalent COM interface if implemented as a separate process. DDE is much easier to implement in code, and offers a particular data model as (name, value) pairs. In the case of real-time data, this model is well suited, and therefore offers the best cost/benefit ratio when programming for real-time data.

However, DDE was not designed to be used over a network. The Cogent solution for this shortcoming is to tunnel/mirror two DataHub instances over a network or the Internet using TCP. Thus, two programs that use only DDE can exchange data across a robust, TCP-enabled link.

Data Definitions

DDE defines data in terms of (service, topic, item), explained as follows:

service

A name used by a DDE server to identify its service to DDE clients. The default DDE service name for the DataHub program is datahub. Unlike most Windows programs, the DataHub program lets you change this name, or add more names if you'd like.

topic

A way to categorize items. This corresponds to a DataHub data domain.

item

A variable that holds a value. This corresponds to a DataHub point.

Here are some service and topic names for several Windows programs:

ApplicationDDE Service NameDDE Topic Name
Cogent DataHubMultiple names can be assigned. The default name is datahub.Any DataHub domain name, the default domain is default.
Microsoft Excel EXCEL The name of the spreadsheet, chart, macro, etc. For example: mysheet.xls
Microsoft Access MSACCESS The name of the table, SQL query, or macro to run.
Microsoft Word WINWORD The name of the document, including the .doc extension.
FoxPro FOXPRO
InTouch Viewer VIEW TAGNAME
FIX DMACS DMDDE DATA
National Instruments' Lookout LOOKOUT The name of the application, without the .lkp extension.
Asymetrix Toolbook TOOLBOOK The name of the toolbook application, with the .tbk extension.

Here are a few service and topic names for financial data feeds:

Data FeedDDE Service NameDDE Topic NameSymbol Example
ADP Shark ML LP IBM.N.Q
Bloomberg BLP M IBM EQUITY,[LAST TRADE]
Bridge BDDE TKR @USH8/LS
FXCM FXPS BID EUR/USD
Future Source (CalcSource) CALCSRC P USH8.LAST
Future Source (ProfNet) PROFDDE LIVE APIU02,LAST
Knight Rider Profit Center QMASTER QUOTE USH8.LAST
METATRADER MT BID USDCHF
METATRADER v. 4 MT4 BID USDCHF
MGFOREX MGFOREX RATES USD
Moneycast WBSERVER SES 19/L (19 is a stock code)
Reuters REUTER IDN USH8 /IBM ,LAST
Telerate WorkStation TWINDDE QUOTES USH8.3 LAST
Universal Market Data Server USDDE QUOTE US8H;LAST

Client and Server

In DDE, the role of client and server in data exchange is fairly clear. A client initiates the activity, and the server responds. To facilitate two-way data transfer, each DataHub instance can each act as both client and server. This is what allows Excel spreadsheets to share data bidirectionally across a network.

Sending and Receiving Data

There are three ways to send and receive ordinary data over DDE. Here is a brief explanation, using a DataHub instance and Microsoft Excel as examples:

Poke  The client sends data for an item directly to the server. In Excel, this is done with a macro. The server does not necessarily reply. The actual data flow is from client to server—from Excel to the DataHub instance.

Request  The client asks the server to send an item's data. In Excel, this is done with a macro. The client receives either the requested value, or NULL if the server can't send the value. The actual data flow is from server to client—from the DataHub instance to Excel.

Advise  The client asks to be notified of any change in the data for an item. If the server agrees to the request, it sends the new value for the item each time its value changes. The DataHub instance can conduct two-way communication with Excel using only this advise capability, as follows: