Results 1 to 4 of 4

Thread: Use DDE to retrieve values

  1. #1
    Join Date
    Feb 2009
    Posts
    117

    Use DDE to retrieve values

    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

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: Use DDE to retrieve values

    This is normal you do not loop until the message!
    You call the getMessage but he spends it on something else!
    If the DDE link in Excel takes a few ms and more you will receive nothing
    So the basic solution is to make a timer, and looping over getMessage with a timeout value
    Something more sophisticated would be a thread

    Looking at the MSDN help on getMessage.

    GetMessage Function


    The getMessage function retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval.

    Unlike getMessage, the PeekMessage function does not wait for a message to be posted before returning.


    An application typically uses the return value to determine whether to end the main message loop and exit the program.

  3. #3
    Join Date
    Feb 2009
    Posts
    117

    Re: Use DDE to retrieve values

    You call the getMessage but he spends it on something else!
    Thank you for your answer but getMessage is blocking:

    Unlike getMessage, the PeekMessage function does not wait for a message to be posted before returning.
    In fact, I put a printf after getMessage and the program gets stuck on getMessage, therefore I do not get any message.

  4. #4
    Join Date
    Mar 2008
    Posts
    258

    Re: Use DDE to retrieve values

    Hi this prehistoric DDE is better to use COM, you can create a link OLE Automation / COM Excel to read / write to an Excel file
    Otherwise I think it works better in the loop of messages from the application process messages DDE.

    What type of project? win32 console UI?

Similar Threads

  1. Replies: 4
    Last Post: 20-01-2012, 11:56 AM
  2. W32 registry values are not getting matched by the default values
    By Angrzej in forum Networking & Security
    Replies: 5
    Last Post: 19-05-2011, 12:23 PM
  3. Retrieve multiple values from java class
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 12:05 AM
  4. What are the RGB values?
    By Renderman21 in forum Operating Systems
    Replies: 3
    Last Post: 21-11-2009, 09:45 AM
  5. How to use enum values in VB
    By $tatic in forum Software Development
    Replies: 1
    Last Post: 10-08-2009, 06:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,916,060.04852 seconds with 16 queries