Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Send a Message to an Application

Posted on 1998-04-14
6
Medium Priority
?
214 Views
Last Modified: 2010-04-10
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.
0
Comment
Question by:khs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1184288
In MS Windows, use SendMessage() or PostMessage().
0
 

Author Comment

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


0
 

Accepted Solution

by:
gds earned 200 total points
ID: 1184290
In 32-bit Windows there are several ways of doing an inter-process communication:

1.  You can set up a piece of global shared memory, using CreateFileMapping, OpenFileMapping and MapViewOfFile.  Then use a named mutex to control access to the shared memory, and a global named event to signal from the source to the client that new data is available.

2.  Use a named pipe.  Make the client app listen on a pipe, and have the source app stuff data into the pipe.  This has the advantage over (1) that the two processes can be on separate computers.

3.  Use an RPC call from the source to the client.  You can configure an RPC to work purely locally using a lightweight RPC, so the processes can be on the same computer.

4.  Failing all of that, use

PostMessage(HWND_BROADCAST,msgMyMessage,0,0)

where msgMyMessage is a userdefined message ID obtained from a call to RegisterWindowMessage.  All top-level windows will receive the message, but (presumably) only your client apps will understand the registered message.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:khs
ID: 1184291
I don't understand your answer.I am a novice.
I am using now MFC 5.0 .
0
 
LVL 11

Expert Comment

by:alexo
ID: 1184292
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?

0
 

Expert Comment

by:Skrobotz
ID: 1184293
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.


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question