您的位置:首页 > 其它

保证只运行一个实例应用程序

2012-08-22 13:16 183 查看



[STAThread]
static void Main()
{
bool createdNew = false;
Mutex mutex = new Mutex(true, “CSharpHowTo_SingleInstanceApp”,
out createdNew);
if (createdNew)
{

//没有运行实例

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{

MessageBox.Show( “You can only run a single instance of this app!”);

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