程序1:检测程序2是否运行,如果是,则发送消息CM_RESTOREPLAY 
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;const
  CM_RESTOREPLAY = WM_USER + $10; {自定义的“恢复”消息}
  MYAPPNAME = '接受测试';type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
  hMutex  : hWnd;
begin
  hMutex:=FindWindow(nil,MYAPPNAME);
  if hMutex<>0 then
  begin
    SendMessage(hMutex,CM_RESTOREPLAY,0,0);
  end;
  ReleaseMutex(hMutex);
end;end.程序2:如果接受到消息CM_RESTOREPLAY,则探出对话框。实际运行中程序1发现程序2正在运行,并且发出了消息,但程序2没有任何反应?????unit UntTest;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;const CM_RESTOREPLAY=WM_USER+$10;type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure ApplicationEventsActionExecute(var Msg: tagMSG; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ApplicationEventsActionExecute(var Msg: tagMSG; var Handled: Boolean);
var
  Tmp : TBitmap;
begin
  if (Msg.message = CM_RESTOREPLAY) then
  begin
    ShowMessage('测试,再次启动');
  end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
  application.onmessage := ApplicationEventsActionExecute;
end;end.