After initiating a conversation, the client interacts with the server by issuing transactions. A transaction is a client's request that the server perform a particular action.

To issue a transaction, the client allocates a shared-memory object, writes data about its request to the object using a DDESTRUCT data structure, then calls WinDdePostMsg to post a transaction message to the server. The transaction message contains the client-window handle and a pointer to the shared-memory object. When the server receives the message, it uses the pointer to access the shared-memory object.

The server responds by allocating a shared-memory object, writing its response to the object using a DDESTRUCT data structure, then calling WinDdePostMsg to post a response message to the client. The response message contains the server-window handle and a pointer to the shared-memory object.

A DDESTRUCT data structure occupies the first part of the memory object. Next comes the item-name string, followed by the actual data being exchanged. The offset fields of the DDESTRUCT data structure must be set to point to the name string and the beginning of the data. The cbData field also must be set to indicate the number of bytes of data.

The sender of a DDE transaction message must allocate a shared-memory object using DosAllocSharedMem, then call DosGiveSharedMem to share the object with the receiving application. To share an object, the sender must know the process identifier of the recipient. The process identifier can be obtained by calling WinQueryWindowProcess for the recipient's window handle. WinDdePostMsg also gives the memory object.

The sender should not try to access the object after sending it to the recipient in a DDE message. After posting a transaction message, WinDdePostMsg automatically frees the shared-memory object from the sender's virtual address space. An application need not call DosFreeMem for this purpose. However, the recipient must call DosFreeMem when it is finished using the object.


[Back] [Next]