Example #1
0
        static void Main(string[] args)
        {
            // Parse for the need to run the program elevated
            Boolean bRunElevated = false, bForceAdmin = false;
            foreach (string strParam in args)
            {
                if (strParam.Equals("-elevate"))
                    bRunElevated = true;
                else if (strParam.Equals("-forceadmin"))
                    bForceAdmin = true;
            }

            // Check if the program can write to the program and avisynth plugin dir
            if (FileUtil.IsDirWriteable(Path.GetDirectoryName(Application.ExecutablePath)) == false)
                bForceAdmin = true;

            // If needed run as elevated process
            if (bForceAdmin && !bRunElevated)
            {
                try
                {
                    Process p = new Process();
                    p.StartInfo.FileName = Application.ExecutablePath;
                    p.StartInfo.Arguments = "-elevate";
                    p.StartInfo.Verb = "runas";
                    p.Start();
                    return;
                }
                catch
                {
                }
            }

            System.Windows.Forms.Application.EnableVisualStyles();

            if (!mySingleInstanceMutex.WaitOne(0, false))
            {
                if (DialogResult.Yes != MessageBox.Show("Running MeGUI instance detected!\n\rThere's not really much point in running multiple copies of MeGUI, and it can cause problems.\n\rDo You still want to run yet another MeGUI instance?", "Running MeGUI instance detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    return;
            }

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            CommandlineParser parser = new CommandlineParser();
            parser.Parse(args);
            MainForm mainForm = new MainForm();
            mainForm.handleCommandline(parser);
            if (parser.start)
                Application.Run(mainForm);
        }
Example #2
0
        public void handleCommandline(CommandlineParser parser)
        {
            foreach (string file in parser.failedUpgrades)
                System.Windows.Forms.MessageBox.Show("Failed to upgrade '" + file + "'.", "Upgrade failed", MessageBoxButtons.OK, MessageBoxIcon.Error);

            if (parser.upgradeData.Count > 0)
            {
                UpdateWindow update = new UpdateWindow(this, Settings);
                foreach (string file in parser.upgradeData.Keys)
                    update.UpdateVersionNumber(file, parser.upgradeData[file]);
                update.SaveSettings();
            }
        }