怎样设置窗体只能启动一次呢?

 
第一种方法:
	  private static void GetCheckProcess()
         {            
            bool createNew;
            using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew))
            {
                if (createNew)
                {
                    Application.Run(new ManagerComputer());
                }
            }
        }

第二种方法:
	    string filename = Process.GetCurrentProcess().MainModule.FileName;
            filename = System.IO.Path.GetFileNameWithoutExtension(filename);
            Process[] pro = Process.GetProcessesByName(filename);
            if (pro.Length == 0)
            {
                Application.Run(new ManagerComputer());
            }

你可能感兴趣的:(C#之窗)