Wince ApplicationProgramThere are many ways to implement inter-process communication, such as clipboard, named pipeline, anonymous pipeline, mailbox, shared memory, file ing, socket, etc, the simplest one is
Wm_copydata message, now write a small example for memo:
There are two programs A and B, A as the sender and B as the receiver.
The program snippets in the (sender) program are as follows:
Hwnd =: findwindow (null, _ T ("B "));
If (null = hwnd)
{
MessageBox (null, _ T ("program B not found"), _ T ("prompt"), null );
}
Char * Buf = new char [10];
Memset (BUF, 0, 10 );
Sprintf_s (BUF, 10, "% s", "hello ");
Copydatastruct CDs;
Zeromemory (& CDs, sizeof (copydatastruct ));
CDs. dwdata = 0;
CDs. cbdata = 10;
CDs. lpdata = (pvoid) BUF;
: Sendmessage (hwnd, // hwnd is the target window handle for receiving messages
Wm_copydata,
Null/* (wparam) hwnd */, // It can be null or a window handle for sending messages
(Lparam) & CDs); // copydatastruct struct pointer
Delete [] Buf;
The B (receiver) program segment is as follows:
Case wm_copydata:
{
MessageBox (null, _ T ("B Program receives the message wm_copydata"), _ T ("prompt"), null );
Copydatastruct * PCDs = (copydatastruct *) lparam;
Printf ("PCDs-> cbdata is: % d \ n", PCDs-> cbdata );
Printf ("PCDs-> lpdata is: % s \ n", (char *) PCDs-> lpdata );
}