Programming Windows: Hello, DDE (Premium)

As noted in Programming Windows: Clipboard and DDE (Premium), Microsoft introduced a technology called Dynamic Data Exchange (DDE) in Windows 2.0 that allowed compatible applications to dynamically share data. Using DDE, it was possible---difficult, but possible---to update shared data in a source application and have it be automatically updated in the destination application. (DDE actually used the terms server and client for this relationship, but I’ll keep it simpler here since Microsoft eventually abandoned that terminology for data sharing.)

DDE was barely documented at first, and it was only natively supported in a handful of applications, at least until Visual Basic arrived. By which point DDE itself had been replaced by a newer technology called Object Linking and Embedding (OLE, which was itself originally based on DDE). But Microsoft kept DDE around, so it eventually became possible to use DDE to create applications in Visual Basic (and elsewhere) that could be the source and/or destination of dynamic data.

Sounds like a neat experiment, no?

With DDE, the source and destination applications would establish a conversation using the DDE protocol, and at the time the conversation was instantiated, it could optionally be configured as a persistent exchange. In that case, the sharing would be dynamic, and the shared data would be “live”: Any change to the data in the source would be reflected in the destination and vice versa.

The canonical real-world use of DDE---arguably the only use---was to host Excel 3.0 (or greater) data in another application. So, I used Excel 3.0, Visual Basic 3, and Windows 3.1 to create a simple hello, world-style example of DDE sharing. No code required.

First, I create a simple Excel spreadsheet in which I added the words Hello, DDE! to cell A1. I saved this worksheet as DDE.XLS in C:\EXCEL. (Windows 3.1 had no concept of a User folder, let alone a Desktop folder.) I intended to use that single cell as the source of the DDE-shared data.

Then, I started Visual Basic 3 and added a text box to the default form. The idea was to use the text box as the destination for the DDE-shared data.

To create the DDE link between the two applications, I returned to Excel, selected cell A1, and then selected Edit > Copy. (Which, oddly used the keyboard shortcut CTRL + INSERT back then.)

In Visual Basic, I selected the text box and then selected Edit > Paste link. Doing so changed several of the text box’s properties, which can be seen in the Visual Basic Properties window. Among them are:

LinkTopic: Set to Excel | C:\EXCEL\DDE.XLS

LinkMode: Set to Automatic, meaning that any changes to the source data will appear in the VB (destination) app.

Text: Changed the text in the text box to “Hello, DDE!”

After checking that the link was working---by running the VB app and then changing the text in Excel, noting that doing so changed the text in the text box in the VB app as well---...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC