Sending message data across processes (sending wm_copydata messages, simple enough)

Source: Internet
Author: User

 1//1. Send form 2 procedure Tform2.button1click (sender:tobject); 3 var 4 h:hwnd; 5 Size:integer; 6 Copydatastruc T:tcopydatastruct; 7 Begin 8 H: = FindWindow (nil, ' receive Window ');   {Find target window by title} 9 if h > 0 then10 begin11 Size: = ByteLength (Edit1.text) + 2; {Two extra bytes are used for the following #0}12 copydatastruct.lpdata: = PChar (Edit1.text + #0);            {The string to be sent, #0 represents PChar end}13 copydatastruct.dwdata: = Wm_copydata;                   {Specifies the message type}14 copydatastruct.cbdata: = Size; {Specifies the size of the data to be sent}15 SendMessage (H, wm_copydata, 0, Integer (@CopyDataStruct)); {Send}16 end;17 end;18 19//2. Receive Form 20//2.1 define receive events Protected22 procedure Wmcopydata (var message:twmcopydata); Message wm_copydata;23 24//2.2 perform receive events procedure Tform2.wmcopydata (Var message:twmcopydata); Begin27 MEMO1.LINES.A DD (PChar (Message.CopyDataStruct.lpData)); end;29 30//2.3 change the form name to procedure tform2.formcreate (sender:tobject); 32 Begin33 Caption: = ' Receive Window '; 

Http://www.cnblogs.com/FKdelphi/p/5843118.html

Sending message data across processes (sending wm_copydata messages, simple enough)

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.