用sendMessage()怎么传字符串到事件并还原出来?SendMessage(Shared^.module, MY_MSG, 0, Integer(tlQQChat));
***************** 事件 *********
procedure TForm1.MYMessageMsg(var Msg:TMessage);
begin
    Form1.Label1.Caption := string(Msg.LParam);
end;这样不行啊,因该怎么弄?

解决方案 »

  1.   

    string类型是个自动控制的字符动态数组,内存地址是不可靠的,用Pchar类型或者array[] of char数组取地址
      

  2.   

    SendMessage(Shared^.module,   MY_MSG,   0,   Integer(tlQQChat));
    *****************   事件   ********* 
    procedure   TForm1.MYMessageMsg(var   Msg:TMessage); 
    begin 
            Form1.Label1.Caption   :=   string(Msg.LParam); 
    end;  
    ====================
    SendMessage(Shared^.module,   MY_MSG,   0,   Integer(@tlQQChat));
    *****************   事件   ********* 
    procedure   TForm1.MYMessageMsg(var   Msg:TMessage); 
    begin 
            Form1.Label1.Caption   :=   pstring(Msg.LParam)^; 
    end; 
     
      

  3.   

    要注意的是,不可以跨进程(最好也不要跨线程)。可能跨线程的时候,建议接收方进行一次复制。另外只可以在SendMessage当中使用,不可以用于PostMessage.
      

  4.   

    type
      aaa= record
        bbb: string
      end;传递结构体的指针应该可以
      

  5.   

    用WM_COPYDATA就可以实现进程间数据共享
      

  6.   

    谢谢各位,因为涉及到不同进程的操作,所以unsigned的方法使用中会读内存越界,
    采用xiezhenghai的方案可行