public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_CurrentDomain_UnhandledException);
            if (args.Length >= 1)
            {
                switch (args[0])
                {
                case "install":
                    Protocol.Reg(RoomTool.PRO);
                    Environment.Exit(0);
                    break;

                case "uninstall":
                    Protocol.UnReg(RoomTool.PRO);
                    Environment.Exit(0);
                    break;

                default:
                    if (args[0].StartsWith(RoomTool.PRO))
                    {
                        RoomTool.Command(args[0]);
                        Environment.Exit(0);
                    }
                    break;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isFirstInstance;

            // Please use a unique name for the mutex to prevent conflicts with other programs
            using (Mutex mtx = new Mutex(true, "YGOClient2", out isFirstInstance)) {
                if (isFirstInstance)
                {
                    MyNotifyIcon notificationIcon = new MyNotifyIcon();
                    notificationIcon.notifyIcon.Visible = true;
                    notificationIcon.Show();
                    Application.Run();
                    notificationIcon.notifyIcon.Dispose();
                }
                else
                {
                    MessageBox.Show("This is running.");
                    // The application is already running
                    // TODO: Display message box or change focus to existing application instance
                }
            }             // releases the Mutex
        }
Exemplo n.º 2
0
		public static void Main(string[] args)
		{
			AppDomain.CurrentDomain.UnhandledException +=new UnhandledExceptionEventHandler(AppDomain_CurrentDomain_UnhandledException);
			if(args.Length >= 1){
				switch(args[0]){
					case "install":
						Protocol.Reg(RoomTool.PRO);
						Environment.Exit(0);
						break;
					case "uninstall":
						Protocol.UnReg(RoomTool.PRO);
						Environment.Exit(0);
						break;
					default:
						if(args[0].StartsWith(RoomTool.PRO)){
							RoomTool.Command(args[0]);
							Environment.Exit(0);
						}
						break;
				}
				
			}
			
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			
			bool isFirstInstance;
			// Please use a unique name for the mutex to prevent conflicts with other programs
			using (Mutex mtx = new Mutex(true, "YGOClient2", out isFirstInstance)) {
				if (isFirstInstance) {
					MyNotifyIcon notificationIcon = new MyNotifyIcon();
					notificationIcon.notifyIcon.Visible = true;
					notificationIcon.Show();
					Application.Run();
					notificationIcon.notifyIcon.Dispose();
				} else {
					MessageBox.Show("This is running.");
					// The application is already running
					// TODO: Display message box or change focus to existing application instance
				}
			} // releases the Mutex
		}