Simple Application of wm_copydata messages on the wince Platform

Source: Internet
Author: User

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 );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.