delphi 简单的发送字符串消息

var
  pMes:^String;
begin
  New(pMes);
  pMes^:=msg;
  PostMessage(Application.handle, WM_Custom, 0, Integer(pMes));
end;

以下是接收

procedure CustomMessages(var Msg: TMsg; var Handled: Boolean);
var
  msgStr: String;
  pMes:^String;
begin
  if Msg.hwnd = Application.handle then
  begin
    case Msg.message of
      WM_Custom:
        begin
          pMes:=Pointer(Msg.LParam);
          msgStr:=pMes^;
          Dispose(pMes);

          showmessage(msgStr);

          Handled := True;
        end;
    else
    end;
  end;
end;
原文地址:https://www.cnblogs.com/h2285409/p/7070049.html