コード例 #1
0
ファイル: Program.cs プロジェクト: jamessdixon/ThunderChicken
 private static void Main()
 {
     using (SingleProgramInstance singleProgramInstance = new SingleProgramInstance("THUNDER"))
     {
         if (!singleProgramInstance.IsSingleInstance)
         {
             singleProgramInstance.RaiseOtherProcess();
         }
         else
         {
             AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandle.CurrentDomain_UnhandledException);
             Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
             string[] commandLineArgs = Environment.GetCommandLineArgs();
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             if ((int)commandLineArgs.Length != 2 || !(commandLineArgs[1] == "/hide"))
             {
                 Application.Run(new Form_Fidget(false));
             }
             else
             {
                 Application.Run(new Form_Fidget(true));
             }
         }
     }
 }
コード例 #2
0
        static void Main(string[] args)
        {
            using (SingleProgramInstance spi = new SingleProgramInstance("x5k6yz"))
            {
                if (spi.IsSingleInstance)
                {
                    StartApplication();
                }
                else
                {
                    // For now, we're just gonna check for one argument.. but eventually we will
                    // need to put in a commandline parser (there's on already done on CodeProject).
                    bool restarting = false;
                    if (args.Length > 0)
                    {
                        if (args[0] == "-restart")
                        {
                            restarting = true;
                        }
                    }

                    if (restarting)
                    {
                        if (spi.IsSingleInstance)
                        {
                            StartApplication();
                        }
                        else
                        {
                            Process[] processes = Process.GetProcessesByName(Assembly.GetExecutingAssembly().GetName().Name);

                            foreach (Process process in processes)
                            {
                                if (!process.Id.Equals(Process.GetCurrentProcess().Id)) // Not this instance?
                                {
                                    process.Kill();                                     // Kill it with fire!
                                }
                            }

                            StartApplication();
                        }
                    }
                    else
                    {
                        spi.RaiseOtherProcess();
                    }
                }
            }
        }
コード例 #3
0
 static void Main()
 {
     using (SingleProgramInstance spi = new SingleProgramInstance("virtualremote"))
     {
         if (spi.IsSingleInstance)
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             Application.Run(new MainForm());
         }
         else
         {
             spi.RaiseOtherProcess();
         }
     }
 }