Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Creating a DDE Server Application in LabWindows/CVI

7 ratings | 1.86 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, which can instruct the server to perform a specific function or send 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 the DDE link.
*callbackData: a pointer to user-defined data.

RegisterDDEServer: registers your application as a valid DDE Server, allowing other Windows applications to connect to it.
ServerDDEWrite: sends data to the client when requested. This can be executed only in response to a DDE_REQUESTDATA event.
AdviseDDEDataReady: signals the client that the value of a hot linked control changed. Set up a hot or warm link before calling this function.
UnregisterDDEServer: unregisters your application as a DDE server.



7 ratings | 1.86 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).