DDE Library Chapter 6
LabWindows/CVI Standard Libraries 6-2 © National Instruments Corporation
DDE Clients and Servers
Interprocess communication with DDE involves a client and a server in each DDE conversation.
A DDE server can execute commands sent from another application, and send and receive
information to and from a client application under Windows. A DDE client can send commands
to a server application to be executed, and request data from a server application.
With the LabWindows/CVI DDE Library, you can write programs to act as a DDE client or
server. A detailed example using Microsoft Excel and LabWindows/CVI follows later in this
chapter to illustrate how to use the DDE Library functions.
To connect to a DDE server from a LabWindows/CVI program, you must know some
information about the application to which you would like to connect. All DDE server
applications have a name and topic that defines the connection. For example, you can connect to
Microsoft Excel as a server in two ways with the ConnectToDDEServer function from a
LabWindows/CVI program. If you want to send commands to be executed by the Excel
application, such as opening worksheets and creating charts, you should specify excel as the
server name and system as the topic name in the call to the ConnectToDDEServer
function. However, if you want to send data to an Excel spreadsheet, you should specify excel
as the server name and the filename of the worksheet that is already loaded in Excel as the topic
name.
If your program acts as a DDE server, where other Windows applications will be sending and
receiving commands and data, you need to call the RegisterDDEServer function in your
program. The RegisterDDEServer function establishes your program as a valid DDE server
so that other applications can connect to it and exchange information. The server callback
function will then be invoked as discussed in the following section.
The DDE Callback Function
Callback functions provide the mechanism for sending and receiving data to and from other
applications through DDE. Similar to the method in which a callback function responds to user
interface events from your User Interface Library object files, a DDE callback function responds
to incoming DDE information.
As shown in Table 6-2, a callback function in a client application can respond to only two types
of DDE messages: DDE_DISCONNECT and DDE_DATAREADY. After you set up a warm link
or hot link (also called an advisory loop) to another application, the callback function defined in
the SetUpDDEHotLink or SetUpDDEWarmLink function will be called whenever the data
values change in the other application, or when the other application is closed.