使用.net和c#从任务栏中删除应用程序图标

我试图在任务栏上显示图标,我就这样做了。

ResourceManager resManager = new ResourceManager("TestAgent.Properties.Resources", GetType().Module.Assembly); notifyicon.Icon = (Icon)resManager.GetObject("TestAgent"); notifyicon.Visible = true; notifyicon.Text = "Test Agent"; this.Hide(); this.ShowInTaskbar = false; this.SetVisibleCore(false); 

另一方面,当尝试从这个方式删除任务栏中的图标时。

 notifyicon.Visible = false; notifyicon = null; rulehandler = null; 

我成功地做到了这一点,但问题是当尝试从任务栏中删除图标时,它从任务栏成功删除图标但不隐藏图标,将鼠标hover在它移除的图标上时。

反正有没有鼠标hover删除图标? 我正在使用c#在Windows窗体中执行此操作

简单地处理它。

在Windows窗体中,您可以订阅全局事件ApplicationExit …

 Application.ApplicationExit += new EventHandler(this.OnApplicationExit); private void OnApplicationExit(object sender, EventArgs e) { notifyicon.Dispose(); } 

简单地写notifyIcon.Visible = false; (关闭窗口之前的资本I),你很高兴。 就如此容易。