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)