已实现,下面是在一个窗体中发送接收消息的例子,两个应用程序间也一样,把自定议的消息常量定义到一个公共头文件就可以了<br>unit Unit3;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br>const WM_MYMESSAGE=WM_USER+100;<br>WM_MYMESSAGE2 = WM_USER+200;<br>type<br> TForm3 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> Button3: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button3Click(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> procedure appmessage(var msg:TMessage);message WM_MYMESSAGE;<br> procedure appmessage2(var msg:TMessage);message WM_MYMESSAGE2;<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form3: TForm3;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm3.Button1Click(Sender: TObject);<br>begin<br> postmessage(handle,WM_MYMESSAGE,1,0);<br><br>end;<br><br><br><br>procedure TForm3.appmessage(var msg:TMessage);<br>begin<br> showmessage(inttostr(msg.WParam));<br>end;<br><br>procedure TForm3.appmessage2(var msg:TMessage);<br>begin<br> showmessage(inttostr(msg.WParam));<br>end;<br><br>procedure TForm3.Button3Click(Sender: TObject);<br>begin<br> postmessage(handle,WM_MYMESSAGE2,2,0);<br>end;<br><br>end.