What Is a Dynamic Data Exchange?

DDE is a type of Dynamic Data Exchange (DDE). Using DDE communication requires two Windows applications, one of which processes information as a server and the other obtains information from the server as a client. The client application sends a message request message to the currently activated server application, and the server application responds according to the information, thereby realizing data exchange between the two programs.

On Windows, OS / 2, and some other operating systems (with third-party development tools), Dynamic Data Exchange (DDE) allows data to be shared or communicated between programs. For example, when you change a table or data item in a spreadsheet program in your database program, the table or data item also needs to be changed in other software you may use. DDE is an inter-process communication that uses shared memory as a common exchange area and provides applications with a protocol or command set and message format. DDE uses a client / server model. In this model, the application requests for data are processed on the client side, while the application's provision of data is processed on the server side. [1]
DDE works:
When two concurrently running programs exchange data through DDE, it is a client / server relationship. Once the client and server establish a connection relationship, the client will be notified immediately when the data in the server changes. The data connection channel established by DDE is bidirectional, that is, the client can not only read the data in the server, but also modify it.
DDE, like the clipboard, supports both standard data formats (such as text, bitmaps, etc.) and custom data formats. But their data transmission mechanism is different. One obvious difference is that clipboard operations are almost always used as a one-time response to user-specified operations, such as selecting a paste command from a menu. Although DDE can also be initiated by the user, it continues to function without the need for further user intervention.
E.g:
Party A applies for a global memory, and then postmessage the memory pointer to Party B, and Party B accesses that global memory according to the received pointer. There are several API functions that do this kind of thing. You can find all the functions starting with Dde in MSDN. Because it is an obsolete technology, even MFC did not encapsulate him. It is difficult to guarantee that it will also appear in future Windows APIs [2]
The content of a DDE conversation is agreed upon by three distinguished names.
1. Application name: The name of the two parties conducting the DDE conversation. The name of the commercial application is given in the product documentation. The program name of "Configuration King" runtime system is "VIEW"; the application name of Microsoft Excel is "Excel"; the name of the executable file is used by the Visual Basic program.
2. Subject: The data domain in question. For "Configuration King", the subject is specified as "tagname"; the subject name of Excel is the name of the spreadsheet, such as sheetl, sheet2, ...; the subject of the Visual Basic program is specified by the LinkTopic attribute value .
3. Project: This is the specific data object being discussed. In the data dictionary of "Configuration King", when the engineering personnel define the I / O variables, they also define the project name. Items in Excel are cells, such as rlc2 (rlc2 represents the cells in the first row and the second column). For Visual Basic programs, a project is the name of a specific text box, label, or picture box [3]
(1) Cold Link (CoolLink): Data exchange is a one-time data transmission, which is the same as the clipboard. The client is not notified when the data in the server changes, but the client can read and write data from the server at any time;
(2) WarmLink: When the data in the server changes, the customer will be notified immediately, and the customer will get the data back after receiving the notification;
(3) HotLink: When the data in the server changes, the client will be notified immediately, and the changed data will be sent directly to the client.
For convenience, Microsoft provides the DDE Management Library (DDEML). DDEML specifically coordinates DDE communication and provides DDE applications with handle string and data exchange services, eliminating early problems caused by inconsistent DDE protocols.
Applications developed using DDEML (client / server) are better than applications that do not use DDEML in terms of operational consistency and communication between programs. In addition, the application of DDEML makes it easier to develop applications that support DDE, because DDEML (this is a DLL) takes on the job of the director of the Home Affairs Department. After using DDEML, in fact, most of the sessions between the client and server are not directly to the other party, but are relayed through DDEML, that is, the Callback function is used to process DDE transactions, and the early message communication is direct.
Before calling other DDEML functions, the client / server must call the DdeInitialize () function to obtain the instance identifier, register the DDECallback function, and specify transaction filtering for the Callback function. For the server, after initializing it with DdeInitialize (), call DdeCreateStringHandle () to create handles identified by Service name, Topics name, and Items name, and then register the server name in the operating system through DdeNameService (). Based on these handles, customers can use the DDE services it provides.
In order to perform a DDE task, many DDEML functions require access to strings. For example: When a client calls the DdeConnect () function to request a session with the server, the client must specify the Service name and Topics name. You can get a specific string handle by calling the DdeCreateStringHandle () function. E.g:
HSZhszServName = DdeCreateStringHandle (idInst, "MyServer", CP_WINANSI);
HSZhszSysTopic = DdeCreateStringHandle (idInst, SZDDESYS_TOPIC, CP_WINANSI);
An application's DDE callback function receives multiple string handles in most DDE transactions. For example: During the XTYP_REQUEST transaction, a DDE server receives two string handles: one identifying the Topics name string and the other identifying the Items name string. You can get the length of the string corresponding to the string handle by calling the DdeQueryString () function, and copy the string to the buffer defined by the application. E.g:
DWORDidInst;
DWORDcb;
HSZhszServ;
PSTRpszServName;
cb = DdeQueryString (idInst, hszServ, (LPSTR) NULL, 0, CP_WINANSI) +1;
pszServName = (PSTR) LocalAlloc (LPTR, (UINT) cb);
DdeQueryString (idInst, hszServ, pszServName, cb, CP_WINANSI);
According to Microsoft MSDN, existing message-based DDE protocol applications are compatible with DDEML applications, that is, message-based DDE applications can talk and trade with DDEML applications. When using DDEML, you must include the ddeml.h header file in the source program file, connect the user32.lib file, and ensure that the ddeml.dll file has the correct system path.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?