日期:2014-05-17 浏览次数:20879 次
[STAThread]
bool isRuned ;
try
{
System.Threading.Mutex mutex = new System.Threading.Mutex(true,"OnlyRunOneInstance", out isRuned);
if (isRuned)
{
Form frm = new Form();
if (frm.IsDisposed == false)
Application.Run(frm);
mutex.ReleaseMutex();
Application.Exit();
}
else
{
MessageBox.Show("已启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception e)
{
}
bool isfind = false;
foreach (Form f in Application.OpenForms)
{
if(f.GetType() == typeof(MyForm))
{
isfind = true;
//说明找到了,做对应的处理,然后跳出循环
break;
}
}