コード例 #1
0
        static void Main(string[] args)
        {
            if (args.Length == 2 && args[0].Equals("-update-mem", StringComparison.OrdinalIgnoreCase))
            {
                performUpdate(args[1]);
            }

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

            bool runAsAdmin = false;

            if (Misc.isRunAsAdministrator())
            {
                runAsAdmin = true;
            }

            loadEmbeddedDlls();

            processUpdate();

            loadMD5Tables();

            string iniPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "installer.ini");

            if (File.Exists(iniPath))
            {
                Installer installer = new Installer();
                if (installer.Run(runAsAdmin))
                {
                    Application.Run(installer);
                }
                if (installer.exitToModder)
                {
                    Application.Run(new MainWindow(runAsAdmin));
                }
            }
            else
            {
                Application.Run(new MainWindow(runAsAdmin));
            }

            unloadEmbeddedDlls();
            Environment.Exit(0);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: epicabsol/MassEffectModder
        static void Main(string[] args)
        {
            if (args.Length > 0 && args[0].Equals("-update-mem", StringComparison.OrdinalIgnoreCase))
            {
                Thread.Sleep(1000);
                try
                {
                    if (args.Length != 2)
                    {
                        throw new Exception();
                    }
                    string baseName = Path.GetFileNameWithoutExtension(args[1]);
                    string fileExe  = baseName.Substring("new-".Length) + ".exe";
                    string filePdb  = baseName.Substring("new-".Length) + ".pdb";
                    if (File.Exists(fileExe))
                    {
                        File.Delete(fileExe);
                    }
                    if (File.Exists(filePdb))
                    {
                        File.Delete(filePdb);
                    }
                    File.Copy(baseName + ".exe", fileExe);
                    File.Copy(baseName + ".pdb", filePdb);

                    Process process = new Process();
                    process.StartInfo.FileName        = fileExe;
                    process.StartInfo.CreateNoWindow  = true;
                    process.StartInfo.UseShellExecute = false;
                    if (!process.Start())
                    {
                        throw new Exception();
                    }

                    Environment.Exit(0);
                }
                catch
                {
                    MessageBox.Show("Failed update MEM!");
                    Environment.Exit(1);
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool runAsAdmin = false;

            if (Misc.isRunAsAdministrator())
            {
                runAsAdmin = true;
            }

            loadEmbeddedDlls();


            cleanupPreviousUpdate();
            string filename = prepareForUpdate();

            if (filename != "")
            {
                filename = unpackUpdate(filename);
            }
            if (filename != "")
            {
                Process process = new Process();
                process.StartInfo.FileName        = filename;
                process.StartInfo.Arguments       = "-update-mem " + filename;
                process.StartInfo.CreateNoWindow  = true;
                process.StartInfo.UseShellExecute = false;
                if (process.Start())
                {
                    unloadEmbeddedDlls();
                    Environment.Exit(0);
                }
                MessageBox.Show("Failed start update MEM instance!");
            }

            loadMD5Tables();

            string iniPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "installer.ini");

            if (File.Exists(iniPath))
            {
                Installer installer = new Installer();
                if (installer.Run(runAsAdmin))
                {
                    Application.Run(installer);
                }
                if (installer.exitToModder)
                {
                    Application.Run(new MainWindow(runAsAdmin));
                }
            }
            else
            {
                Application.Run(new MainWindow(runAsAdmin));
            }

            unloadEmbeddedDlls();
            Environment.Exit(0);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            loadEmbeddedDlls();

            if (args.Length == 4)
            {
                AttachConsole(-1);
                string option   = args[0];
                string game     = args[1];
                string inputDir = args[2];
                string outMem   = args[3];
                int    gameId;
                try
                {
                    gameId = int.Parse(game);
                }
                catch
                {
                    gameId = 0;
                }
                if (gameId != 1 && gameId != 2 && gameId != 3)
                {
                    Console.WriteLine("Error: wrong game id!");
                    Environment.Exit(1);
                }
                else
                {
                    if (option.Equals("-convert-to-mem", StringComparison.OrdinalIgnoreCase))
                    {
                        if (!Directory.Exists(inputDir))
                        {
                            Console.WriteLine("Error: intput path not exists: " + inputDir);
                            Environment.Exit(1);
                        }
                        else
                        {
                            Console.WriteLine(Environment.NewLine + Environment.NewLine +
                                              "--- MEM v" + Application.ProductVersion + " command line --- " + Environment.NewLine);
                            if (!CmdLineConverter.ConvertToMEM(gameId, inputDir, outMem))
                            {
                                Environment.Exit(1);
                            }
                        }
                    }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                bool runAsAdmin = false;

                if (Misc.isRunAsAdministrator())
                {
                    runAsAdmin = true;
                }

                string iniPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "installer.ini");
                if (File.Exists(iniPath))
                {
                    Installer installer = new Installer();
                    if (installer.Run(runAsAdmin))
                    {
                        Application.Run(installer);
                    }
                    if (installer.exitToModder)
                    {
                        Application.Run(new MainWindow(runAsAdmin));
                    }
                }
                else
                {
                    Application.Run(new MainWindow(runAsAdmin));
                }
            }

            unloadEmbeddedDlls();
        }