Exemple #1
0
        public static void Main(string[] Args)
        {
            try
            {
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

                mutex = new Mutex(true, identifier, out isNotRunning);
                if (isNotRunning)
                {
                    System.Windows.Forms.Application.EnableVisualStyles();
                    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

                    System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

                    application = Application.CreateInstance();
                    if (application != null)
                    {
                        application.OnExit += new EventHandler(application_OnExit);
                        application.Initialize();

                        frm = new MainForm(application);
                        frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);

                        if (application.isNotify)
                        {
                            frm.ShowInTaskbar = false;
                            frm.WindowState = FormWindowState.Minimized;
                        }

                        System.Windows.Forms.Application.Run(frm);
                    }
                }
                else
                {
                    // 13.02.2013 - убрано, так как повторный запуск стал нормальным явлением!
                    //MessageBox.Show("Приложение уже запущено", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
            }
        }