This example uses WinDdeInitiate to initiate-during the creation of a client window-a dynamic data exchange (DDE) conversation with any available server applications, asking that the server applications respond for each topic they can support. It also allocates the shared memory that will be used once the conversation is established.

#define INCL_WINDDE             /* Window DDE Functions         */
#define INCL_DOSMEMMGR          /* Memory Manager values        */
#include <os2.h>

BOOL  fSuccess;         /* success indicator                    */
HWND  hwndClient;       /* client window                        */
char  pszAppName[15]="";/* server application                   */
char  pszTopicName[15]="";/* topic                              */
CONVCONTEXT Context;
PDDESTRUCT  pddeData;   /* DDE structure                        */

case WM_CREATE:
     /* issue DDE initialize call */
     fSuccess = WinDdeInitiate(hwndClient, pszAppName,
                               pszTopicName, &Context);

     /* allocate shared memory for conversation data */
     DosAllocSharedMem((PVOID)pddeData,"DDESHAREMEM",
                       sizeof(DDESTRUCT) + 50,
                       PAG_READ | PAG_WRITE | PAG_COMMIT |
                       OBJ_GIVEABLE | OBJ_GETTABLE);


[Back] [Next]