Link to home
Start Free TrialLog in
Avatar of khs
khs

asked on

Send a Message to an Application

I'd like to send a message in my application to other
applications.
my application receives data from serial port and process
these data. once i finish this process  i want to notify
 any other applications of getting theses data or use theses data.how can i send message to other application.
Avatar of yonat
yonat

In MS Windows, use SendMessage() or PostMessage().
Avatar of khs

ASKER

sorry! your answer is not suite for me. i'd like to konw detailed
example code.
I already know SendMessage() and PostMessage() functions.


ASKER CERTIFIED SOLUTION
Avatar of gds
gds

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of khs

ASKER

I don't understand your answer.I am a novice.
I am using now MFC 5.0 .
Sending messages to other applications is easy.  You need to aquire the window handle of the other application window you'd like to send messages to.  For example, you can use:

    hwnd = FindWindow(NULL, "the title of the window");
    if (hwnd != NULL)
        PostMessage(hwnd, message, 0, 0);

Or, you can broadcast a message to all windows in the system:

    PostMessage(HWND_BROADCAST, message, 0, 0);

Where "message" is either one of the standard messages (WM_xxx) or a user-defined one.

You can define messages for inter-application communications by asking Windows to provide a unique message number:

    message = RegisterWindowMessage("Message ID string");

Note that the program that receives the message should now how to deal with it :-)

Is this a satisfactory answer?

Use the Command:

In the Sending Program use
RegisterWindowMessage(..)
and
PostMessage(..)

In the program that must recieve the message use the command
RegisterWindowMessage(..) and wrote a Routine to process the Message.