Creating a DDE Client Application in CVI

Publish Date: Sep 06, 2006 | 10 Ratings | 2.10 out of 5 | Print

Before creating a dynamic data exchange (DDE) application, you must decide whether to use your application as a server or client. A server primarily waits for other Windows applications (clients) to send commands and then acts upon that command, whether the server performs a specific function or sends data back to the client. A client initiates conversations with the server by asking the server to perform a task. For example, if you need to send data acquired from your LabWindows/CVI application to a report created in Microsoft Excel, your application acts as the client and Excel acts as the server. Conversely, if you have a Visual Basic application that requests data acquired from your LabWindows/CVI application, your application acts as the server.

Note: If you communicate to a third-party software package through DDE, you must know what command strings the software understands. LabWindows/CVI provides only generic DDE functions that you can use to send, receive, and execute commands. For information on the actual command strings and format of the data, consult the user manuals of the third-party software package.

The server and client each have their own DDE callback function, much like a control on the graphical user interface has its own callback function. The callback function for a control executes any time an event occurs on that particular control. The same applies to DDE callback functions, except the client triggers the event in the server’s callback function and vice versa, instead of a mouse click initiating the event. A DDE callback function has the following format:

int DDEcallback (unsigned handle, char *topicName, char *itemName, int xType, int dataFmt, int dataSize, void *dataPtr, void *callbackData);

handle: a number that identifies the client server connection.
*topicName: a string that the server defines as a valid topic. If a client has multiple connections to a server, you can use *topicName to distinguish between each connection.
*itemName: a string that identifies a particular task.
xType: a number that identifies a specific event for the client or server.
dataFmt: a number that corresponds to the format of the data sent across the DDE link. These are defined Windows types, such as CF_TEXT (=1) and CF_BITMAP (=2).
dataSize: the number of bytes that were sent across the DDE link.
*dataPtr: a pointer to the data that has been sent across.
*callbackData: a pointer to user-defined data.

A client can call the following DDE functions:
ConnectToDDEServer: establishes the connection between your client and the named server.
ClientDDEWrite: sends data to the server application.
ClientDDEExecute: sends the command for the server to execute.
ClientDDERead: requests data for the server to send.
SetUpDDEHotLink/SetUpDDEWarmLink: sets up a link (advisory loop) between the client and the server. Hot and warm links are used to inform the client automatically of changes in a particular data item on the server. LabWindows/CVI does not distinguish between the two, but the functions are provided because some DDE server applications offer only one type of link.
TerminateDDELink: allows the client to terminate a DDE link previously set up using SetUpDDEHotLink or SetUpDDEWarmLink.
DisconnectFromDDEServer: terminates the connection between the client and the server.

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No