Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to be notified of any update from Dynamic Data Exchange (DDE)?
    primarykey
    data
    text
    <p>I was following the example from <a href="http://support.microsoft.com/kb/279721" rel="nofollow noreferrer">How to use Dynamic Data Exchange (DDE) with Word and Excel from Visual C++</a> and I somehow managed to able able to retrieve the value from the Excel.</p> <p>Now the question is, with this example, I have to run the application over again to get the necessary update. How do I make it in such a way that if there is an update in Excel, my application will be notified? DdeAdvise?</p> <p>Thanks in advance! Excel is just an example! And no, I need DDE not COM even if its old.</p> <pre><code>// DDEExample.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include &lt;windows.h&gt; #include "ddeml.h" #define PAUSE system("pause") HDDEDATA CALLBACK DdeCallback(UINT uType, UINT uFmt, HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ULONG_PTR dwData1, ULONG_PTR dwData2) { printf("uType: %d", uType); switch(uType) { case XTYP_REQUEST: printf("XTYP_REQUEST\n"); break; } return 0; } void DDERequest(DWORD idInst, HCONV hConv, char* szItem, char* sDesc) { HSZ hszItem = DdeCreateStringHandle(idInst, szItem, 0); HDDEDATA hData = DdeClientTransaction(NULL,0,hConv,hszItem,CF_TEXT, XTYP_REQUEST,5000 , NULL); if (hData==NULL) { printf("Request failed: %s\n", szItem); } else { char szResult[255]; DdeGetData(hData, (unsigned char *)szResult, 255, 0); printf("%s%s\n", sDesc, szResult); } } int _tmain(int argc, _TCHAR* argv[]) { char szApp[] = "EXCEL"; char szTopic[] = "C:\\Test.xlsx"; char szCmd1[] = "[APP.MINIMIZE()]"; char szItem1[] = "R1C1"; char szDesc1[] = "A1 Contains: "; UINT uiResult; DWORD m_dwDDEInstance = 0; uiResult = DdeInitialize(&amp;m_dwDDEInstance, (PFNCALLBACK) &amp;DdeCallback, APPCLASS_STANDARD|APPCMD_CLIENTONLY, 0); if(uiResult != DMLERR_NO_ERROR) { printf("DDE Initialization Failed: 0x%04x\n", uiResult); return FALSE; } printf("m_dwDDEInstance: %u\n", m_dwDDEInstance); //PAUSE; HSZ hszApp, hszTopic; HCONV hConv; hszApp = DdeCreateStringHandle(m_dwDDEInstance, szApp, 0); hszTopic = DdeCreateStringHandle(m_dwDDEInstance, szTopic, 0); hConv = DdeConnect(m_dwDDEInstance, hszApp, hszTopic, NULL); DdeFreeStringHandle(m_dwDDEInstance, hszApp); DdeFreeStringHandle(m_dwDDEInstance, hszTopic); if(hConv == NULL) { printf("DDE Connection Failed.\n"); } DDERequest(m_dwDDEInstance, hConv, szItem1, szDesc1); DdeDisconnect(hConv); DdeUninitialize(m_dwDDEInstance); PAUSE; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload