title: How can I send data between 2 applications using SendMessage?
body: <p>I have 2 applications- Manager with this code:</p>
  
  <pre><code>procedure TForm1.CopyData(var Msg: TWMCopyData);
  var sMsg: String;
  begin
    if IsIconic(Application.Handle) then Application.Restore;
    sMsg := PWideChar(Msg.CopyDataStruct.lpData);
  
    Caption := Caption+'#'+sMsg;
  
    Msg.Result := 123;
  end;
  
  procedure TForm1.Button1Click(Sender: TObject);
  const
    WM_MY_MESSAGE = WM_USER + 1;
  var
    h: HWND;
  begin
    Caption := 'X';
    h := FindWindow('TForm1', 'Client');
    if not IsWindow(h) then Exit;
  
    Caption := Caption+'@';
    SendMessage(h, WM_MY_MESSAGE, 123, 321);
  end;
  </code></pre>
  
  <p>And Client with:</p>
  
  <pre><code>procedure TForm1.WndProc(var Message: TMessage);
  const
    WM_MY_MESSAGE = WM_USER + 1;
  var DataStruct: CopyDataStruct;
      S: String;
      h: HWND;
  begin
    inherited;
    if Message.Msg &lt;&gt; WM_MY_MESSAGE then Exit;
  
  
    h := FindWindow('TForm1', 'Manager');
    if not IsWindow(h) then Exit;
  
    Message.Result := 123;
  
    S := Edit2.Text + '@' + Edit1.Text;
    DataStruct.dwData := 0;
    DataStruct.cbData := 2*Length(S)+1;
    DataStruct.lpData := PWideChar(S);
  
    Caption := Caption + '#';
  
    PostMessage(h, WM_CopyData, Form1.handle, integer(@DataStruct));
  end;
  </code></pre>
  
  <p>The code works- but only once.
  Manager sends 2 integers: 123 and 321 as a "wake up" message to the Client.
  Client responds by sending contents of Edit1 + Edit2.
  Then Manager gets this data and shows on its caption.</p>
  
  <p>Why does it work only once? After I click Button1 again it does nothing.</p>