首页 > 其他 > 详细

禁止程序启动2次

时间:2015-04-29 19:01:01      阅读:138      评论:0      收藏:0      [点我收藏+]

static class Program
{
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
    bool createdNew = false;
    Mutex mutex = new Mutex(false, "singlestart", out createdNew);
    if (!createdNew)
    {
      MessageBox.Show("Can‘t start application twice!");
      Application.Exit();
      return;
    }
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new ACSTest());
  }
}

禁止程序启动2次

原文:http://www.cnblogs.com/chengshuiqiang/p/4466524.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!