您的位置:首页 > 其它

winform程序是否重复运行

2016-01-13 18:54 267 查看
bool ret;

System.Threading.Mutex m = new System.Threading.Mutex(true, Application.ProductName, out ret);

if (ret)

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

//System.Windows.Forms.Application.DoEvents();

Application.Run(new Login());

m.ReleaseMutex();

}

else

{

MessageBox.Show("程序已经在运行,不可重复运行!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);

Application.Exit();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: