LPARAM應為COPYDATASTRUCT類型指針!WM_COPYDATA 
wParam = (WPARAM) (HWND) hwnd;            // handle of sending window 
lParam = (LPARAM) (PCOPYDATASTRUCT) pcds; // pointer to structure with data 
 
Parameters
hwnd 
Handle to the window passing the data. 
pcds 
Pointer to a COPYDATASTRUCT structure that contains the data to be passed. 

解决方案 »

  1.   

    定义TCopyDataStruct结构,分配内存,赋值,得到要传递到窗口的句柄,
    发送消息,释放内存.
    var
      CDS: TCopyDataStruct;
      HD: THandle;
    begin
      CDS.cbData:=Length(Edit1.Text)+1;
      GetMem(CDS.lpData, CDS.cbData ); 
      StrCopy(CDS.lpData, PChar(Edit1.Text));
      HD:=FindWindow(nil, 'Form2'); 
      if HD<>0 then 
        SendMessage(HD, WM_COPYDATA, Handle, Cardinal(@CDS))
      else ShowMessage('The window is not found!');
      RreeMem(CDS.lpData, CDS.cbData );