我使用 Visual Studio 2012,Windows 窗体。单击桌面上的快捷方式时,我需要从系统托盘恢复应用程序。
我使用此代码可以防止同一应用程序的双重距离,但不能从系统托盘打开应用程序。
[STAThread]
static void Main()
{
string mutex_id = "my application";
using (Mutex mutex = new Mutex(false, mutex_id))
{
if (!mutex.WaitOne(0, false))
{
Form1 fForm;
fForm = new Form1();
fForm.Show();
fForm.WindowState = FormWindowState.Normal;
fForm.ShowInTaskbar = true;
// MessageBox.Show("Instance Already Running!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
我在stackoverflow中阅读了一些问题,但没有运气。我需要在这段代码中修改什么?提前致谢!