zoukankan      html  css  js  c++  java
  • 限制程序重复执行

    private void MainWindow_Load(object sender, System.EventArgs e)
    {

        Process[] processes=Process.GetProcessesByName("MYEXENAME");
          if( processes != null)
         {
        if( (processes.Length)== 2)  //第2个进程
        {
           processes[1].CloseMainWindow();

          }
       }
    }

    STAThread]
            static void Main(string[] args)
            {
                //保证该程序只有一个在运行
                bool createdNew;
                System.Threading.Mutex mutex_Application = new System.Threading.Mutex(true,"test",out createdNew);
                if (!createdNew)
                {
                    MessageBox.Show("本程序只允许同时运行一个!");
                    return;
                }
            
                Application.Run();
                
            }        

  • 相关阅读:
    ASP.NET Web Form(八)
    ASP.NET Web Form(八)
    软考知识点总结
    软考知识点总结
    c# 引用外部dll
    c# 引用外部dll
    ORA600 [Kcbz_check_objd_typ_1] Running a Job (Doc ID 785899.1)
    oracle创建em
    1918: 等值数目
    1917: 支配值数目
  • 原文地址:https://www.cnblogs.com/jhtchina/p/82883.html
Copyright © 2011-2022 走看看