unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
    tmphandle:Thandle;
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
begin
  tmphandle:=Findwindow(nil,pchar('test'));
  SendMessage(tmphandle,wm_close,0,0);
  Timer1.Enabled :=False;
end;procedure TForm1.FormActivate(Sender: TObject);
begin
  Application.MessageBox('test','test',0);
end;end.