// knobodde.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "windows.h" #include using namespace std; char szAppCaption[] = "Using DDE for Communications"; char szAppName[] = "sample_server"; char szTopic[] = "edit_field_data"; HINSTANCE hInst; DWORD idInst; HWND hwndApp; char szBuffer[8192]; HDDEDATA CALLBACK DDECallBack (UINT iType, UINT iFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, DWORD dwData1, DWORD dwData2) { char dataMsg[] = "yo from knobo"; DWORD cb; switch (iType) { case XTYP_REGISTER: cout << "Callback: XTYP_REGISTER\n"; return (HDDEDATA) NULL; case XTYP_UNREGISTER: cout << "Callback: XTYP_UNREGISTER\n"; // TODO return (HDDEDATA) NULL; case XTYP_ADVDATA: cout << "Callback: XTYP_ADVDATA\n"; // TODO return (HDDEDATA) DDE_FACK; case XTYP_XACT_COMPLETE: cout << "Callback: XTYP_XACT_cOMPLETE\n"; // return (HDDEDATA) NULL; case XTYP_DISCONNECT: cout << "Callback: XTYP_DISCONNECT\n"; // hsz1 A handle to the topic name. If this parameter is NULL, the client is requesting a conversation on all topic names that the server supports. // hsz2 A handle to the service name. If this parameter is NULL, the client is requesting a conversation on all service names that the server supports. return (HDDEDATA) NULL; case XTYP_WILDCONNECT: HSZPAIR ahszp[2]; HSZ hszSvc; HSZ hszTopic; hszSvc = DdeCreateStringHandle(idInst, (LPCWSTR) "KNOBO", CP_WINANSI); hszTopic = DdeCreateStringHandle(idInst, (LPCWSTR) "Random", CP_WINANSI); ahszp[0].hszSvc = hszSvc; ahszp[0].hszTopic = hszTopic; ahszp[1].hszSvc = NULL; ahszp[1].hszTopic = NULL; cout << "Callback: XTYP_WILDCONNECT\n"; // return (HDDEDATA) NULL; /* DdeCreateDataHandle( idInst, // instance identifier (LPBYTE) &ahszp, // pointer to HSZPAIR array sizeof(HSZ) * 2, // length of the array 0, // start at the beginning (HSZ) NULL, // no item name string 0, // return the same format 0); // let the system own it ; */ case XTYP_CONNECT: cout << "Callback: XTYP_CONNECT\n"; // hsz1 A handle to the topic name. // hsz2 A handle to the service name. PSTR pszServName; cb = DdeQueryString(idInst, hsz1, (LPTSTR) NULL, 0, CP_WINANSI) + 1; pszServName = (PSTR) LocalAlloc(LPTR, (UINT) cb); DdeQueryString(idInst, hsz1, (LPWSTR) pszServName, cb, CP_WINANSI); wcout << "Printing pszSerName: " << pszServName << ";" <