参照 程序元2000的代码UNIT1
USES shellaoi,.....;
....
const WM_NOTIFYICON= WM_USER + 1;
  private
  NotifyData:TnotifyIconData;
procedure ADDIcon;
procedure RemoveIcon;
protected
  procedure OnNotifyIcon(VAR message :Tmessage);
message WN_NOTIFYICON;
procedure TFORM1.ADDICON;
begin
  Notifydata.cbSize:=sizeof(notifydata);
  with Notifydata do
  begin
  Wnd:=Handle;
  uID:=1;
  uFlags:=NIF_TIP OR NIF_ICON OR NIF_MESSAGE;
  hICON:=APPLICATION.ICON.Handle;
  szTip:='你的程序'; 
  uCallbackMessage:=WM_NOTIFYICON;
end;
Shell_NotifyIcon(NIM_ADD,@Notifydata);
end;procedure Tform1.RemoveIcon;
begin
  NotifyIcon.Uid:=1;
  Shell_NotifyIcon(NIM_DELETE,@NOTIFYDATA);
end;procedure TForm1.Button1click(sender:tobject);
begin
  addicon;
end;procedure Tform2.buttonclick(sender:tobject);
begin 
  removeicon;
end;在form1上放一个popmenu,
procedure Tform1.onNotifyIcon(var Message:Tmessage);
var mousepos:tpoint;
begin
  if Message.lparam= WM_LBUTTONDBLCLK then
  showmessage('运行了?')
  else
  if (Message.lparam= WM_LBUTTONDOWN) then
  Begin
    GetCursorpos(MousePos);
    Setforegroudwindow(application.handle);
    Application.ProcessMessages;
    popmenu.popup(mousepos.x,mousepos.y);
  end;
end;