using System.Windows.Forms; using System.Drawing; private NotifyIcon notifyIcon; private void createNotify() { notifyIcon = new NotifyIcon(); notifyIcon.Text = System.Windows.Forms.Application.ProductName; notifyIcon.Visible = true; ShowInTaskbar = false; notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath); var open = new System.Windows.Forms.MenuItem("显示"); //open.Click += Open_Click; var hide = new System.Windows.Forms.MenuItem("隐藏"); //hide.Click += Hide_Click; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[] { open, hide }); //notifyIcon.MouseDoubleClick += _notifyIcon_MouseDoubleClick; }