http://www.codeproject.com/Articles/32908/C-Single-Instance-App-With-the-Ability-To-Restore

 

 

   /// <summary>
        
/// The main entry point for the application.
        
/// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool onlyInstance = false;
            Mutex mutex = new Mutex(true"RedirectorConfigurationTool"out onlyInstance);
            if (!onlyInstance)
            {
                MessageBox.Show("Only one instance can be lunched at the same time");
                return;
            }
            else
            {
                Application.Run(new ConfigurationTool());
            }
        }

 

posted on 2012-07-11 15:45  higirle  阅读(179)  评论(0编辑  收藏  举报