Use WM_COPYDATA to send data between processes

Posted by Charles Gargent on Stack Overflow See other posts from Stack Overflow or by Charles Gargent
Published on 2010-03-15T23:10:36Z Indexed on 2010/03/15 23:19 UTC
Read the original article Hit count: 297

Filed under:
|
|
|

I wish to send text between processes. I have found lots of examples of this but none that I can get working. Here is what I have so far:

for the sending part:

COPYDATASTRUCT CDS;
CDS.dwData = 1;
CDS.cbData = 8;
CDS.lpData = NULL;
SendMessage(hwnd, WM_COPYDATA , (WPARAM)hwnd, (LPARAM) (LPVOID) &CDS);

the receiving part:

case WM_COPYDATA:
COPYDATASTRUCT* cds = (COPYDATASTRUCT*) lParam;

I dont know how to construct the COPYDATASTRUCT, I have just put something in that seems to work. When debugging the WM_COPYDATA case is executed, but again I dont know what to do with the COPYDATASTRUCT.

I would like to send text between the two processes.

As you can probably tell I am just starting out, I am using GNU GCC Compiler in Code::Blocks, I am trying to avoid MFC and dependencies.

© Stack Overflow or respective owner

Related posts about c++

Related posts about ipc