Exemplo n.º 1
0
        static void Main()
        {
            //CreateDesktopShortCut();
            Process process = RuningInstance();

            if (process == null)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(ConfigClient.GetInstance());
            }
            else
            {
                MessageBox.Show("该应用程序已经在运行中,请留意任务栏或托盘区!");
                HandleRunningInstance(process);
                FlashWindow(process.MainWindowHandle, true);
                //System.Threading.Thread.Sleep(1000);
                //System.Environment.Exit(1);
            }
            //bool createNew;
            //using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew))
            //{
            //    if (createNew)
            //    {
            //        Application.EnableVisualStyles();
            //        Application.SetCompatibleTextRenderingDefault(false);
            //        Application.Run(Form1.GetInstance());
            //    }
            //    else
            //    {
            //        MessageBox.Show("应用程序已经在运行中...");
            //        System.Threading.Thread.Sleep(1000);
            //        System.Environment.Exit(1);
            //    }
            //}
        }