这个问题答过很多次了,还有人问!
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ShellAPI,
  StdCtrls, Menus;const
  WM_TRAYNOTIFY = WM_USER+100;type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure TrayNotifyMessage(var Sender: TMessage); message WM_TRAYNOTIFY;
    procedure MarkTaskBarIcon(Sender: TObject);
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  tnd : TNOTIFYICONDATA;
implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
   Application.OnMinimize := MarkTaskBarIcon;
end;procedure TForm1.MarkTaskBarIcon(Sender: TObject);
begin
   Form1.Visible := False;
   tnd.cbSize := sizeof(tnd);
   tnd.Wnd := Handle;
   tnd.uID := 128;
   tnd.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
   tnd.uCallbackMessage := WM_TRAYNOTIFY;
   tnd.hIcon := Application.Icon.Handle;
   StrPCopy(tnd.szTip,Application.Title);
   Shell_NotifyIcon(NIM_ADD,@tnd);
end;procedure TForm1.TrayNotifyMessage(var Sender: TMessage);
begin
   if Sender.LParam = WM_LBUTTONDBLCLK then
  begin
    Shell_NotifyIcon(NIM_DELETE,@tnd);
    Form1.Visible := True;
    Application.Restore;
    Application.BringToFront;
  end;
     if  wm_size=1 then
     
end;end.