Hello to all.
I would like to communicate with an application using DDE. I tried with Excel by entering a formula "= app | topic_ Name" and it works very well.
I tried under Visual C + + express but I have not succeeded.
Code:
char * szApplication = "app";
char * szTopic = "TOPIC";
ATOM atomApplication = * szApplication == 0?
NULL: GlobalAddAtom (szApplication);
ATOM atomTopic = * szTopic == 0?
NULL: GlobalAddAtom (szTopic);
printf ( "Sending message ... \ n");
SendMessage (HWND_BROADCAST,
WM_DDE_INITIATE,
(WParam) NULL,
MAKELONG (atomApplication, atomTopic));
printf ( "message sent \ n");
if (atomApplication! = NULL)
GlobalDeleteAtom (atomApplication);
if (atomTopic! = NULL)
GlobalDeleteAtom (atomTopic);
printf ( "Waiting for a message \ n");
MSG message;
GetMessage (& message,
NULL,
0,
0);
printf ( "Message received \ n");
Sending the message seems to be OK but I do not get any response.
If someone sees an error in my program or an example (simple) to use DDE in C it would be nice.
Thank you
Bookmarks