Hi there,

I register a custom message with RegisterWindowMessage function. I would
like to pass <char*> messages via the message:

char buf[80];
.... // fill the buf with a message
SendMessage( HWND_BROADCAST, MYMESSAGE, (WPARAM)buf, NULL );

this of course does not work as expected: the array is correctly received
only in the process that sends the message. all other processes cannot see
the message data (I suppose this is due to memory beeing virtually adressed
in each process).

my question is: how then should I declare the memory to be able to pass the
data to another process as <char*>?

I've tried to alloc the memory globally (via GlobalAlloc) and pass the
pointer but with no result. The only solution I've found is to register the
data as an atom (GlobalAddAtom) as pass the atom handle. This solution,
however, does not look like a general one.

thanks in advance for your help,
Wiktor Zychla

Re: <char*> data with process-to-process messages by Scott

Scott
Mon Mar 01 07:02:14 CST 2004

Wiktor Zychla wrote:
> Hi there,
>
> I register a custom message with RegisterWindowMessage function. I would
> like to pass <char*> messages via the message:
>
> char buf[80];
> .... // fill the buf with a message
> SendMessage( HWND_BROADCAST, MYMESSAGE, (WPARAM)buf, NULL );
>
> this of course does not work as expected: the array is correctly received
> only in the process that sends the message. all other processes cannot see
> the message data (I suppose this is due to memory beeing virtually adressed
> in each process).
>
> my question is: how then should I declare the memory to be able to pass the
> data to another process as <char*>?
>
> I've tried to alloc the memory globally (via GlobalAlloc) and pass the
> pointer but with no result. The only solution I've found is to register the
> data as an atom (GlobalAddAtom) as pass the atom handle. This solution,
> however, does not look like a general one.
>
> thanks in advance for your help,
> Wiktor Zychla
>
>

The solution is to use the WM_COPYDATA message. With this message the
OS will copy the passed data from one process space to the other.

--
Scott McPhillips [VC++ MVP]