Exemple #1
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            SetTitle("(Checking)");
            Task.Factory.StartNew(GetGeneral);
            TrackingQueue.Enqueue("startup");

            Settings_Loaded(this, new EventArgs());
            UpdateIcon();

            //Add this after otherwise it will save immediately due to RegionList.SelectedIndex
            Settings.PropertyChanged += Settings_PropertyChanged;

            //Start after the form is shown otherwise Invokes will fail
            Connection.Start();
            Injector.Start();
            launcher.Start();

            //Fixes the team controls size on start as they keep getting messed up in the WYSIWYG
            MainForm_Resize(this, new EventArgs());

            try
            {
                var filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "lolbans", "LoLLoader.dll");
                if (File.Exists(filename))
                {
                    StaticLogger.Info("Uninstalling old loader");

                    var shortfilename = AppInit.GetShortPath(filename);

                    var dlls = AppInit.AppInitDlls32;
                    if (dlls.Contains(shortfilename))
                    {
                        dlls.Remove(AppInit.GetShortPath(shortfilename));
                        AppInit.AppInitDlls32 = dlls;
                    }

                    if (File.Exists(filename))
                    {
                        File.Delete(filename);
                    }
                }
            }
            catch (SecurityException se)
            {
                StaticLogger.Warning(se);
            }
            catch (Exception ex)
            {
                StaticLogger.Error("Failed to uninstall " + ex);
            }
        }
Exemple #2
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            TrackingQueue.Enqueue("startup");

            Settings_Loaded(this, new EventArgs());
            UpdateStatus();

            //Add this after otherwise it will save immediately due to RegionList.SelectedIndex
            Settings.PropertyChanged += Settings_PropertyChanged;

            Settings.ModuleResolver = "Toolhelp32Snapshot";

            VersionLabel.Text = "v" + Version;

            //Start after the form is shown otherwise Invokes will fail
            Connection.Start();
            Injector.Start();
            launcher.Start();

            //Fixes the team controls size on start as they keep getting messed up in the WYSIWYG
            MainForm_Resize(this, new EventArgs());

            try
            {
                RegistryKey installed_versions = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
                string[]    version_names      = installed_versions.GetSubKeyNames();
                //version names start with 'v', eg, 'v3.5' which needs to be trimmed off before conversion
                double framework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1), CultureInfo.InvariantCulture);

                if (framework < 4.0)
                {
                    if (MessageBox.Show("The Elophant Client requires the .NET Framework 4.0 Full version. Would you like to download it?", ".NET Framework 4.0 Full Not Found", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process.Start("http://www.microsoft.com/en-us/download/details.aspx?id=17718");
                    }

                    MessageBox.Show("The Elophant Client will now close.");
                    Process.GetCurrentProcess().Kill();
                    return;
                }
            }
            catch (Exception ex)
            {
                StaticLogger.Error(ex.ToString());
                MessageBox.Show("An unknown exception has occurred. Check the log for more information.");
                Process.GetCurrentProcess().Kill();
                return;
            }

            try
            {
                var filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "lolbans", "LoLLoader.dll");
                if (File.Exists(filename))
                {
                    StaticLogger.Info("Uninstalling old loader.");

                    var shortfilename = AppInit.GetShortPath(filename);

                    var dlls = AppInit.AppInitDlls32;
                    if (dlls.Contains(shortfilename))
                    {
                        dlls.Remove(AppInit.GetShortPath(shortfilename));
                        AppInit.AppInitDlls32 = dlls;
                    }

                    if (File.Exists(filename))
                    {
                        File.Delete(filename);
                    }
                }
            }
            catch (SecurityException se)
            {
                StaticLogger.Warning(se);
            }
            catch (Exception ex)
            {
                StaticLogger.Error("Failed to uninstall. Message: " + ex);
            }

            // NOT SURE IF THIS WORKS - TRYING TO AVOID THE USE OF AN INSTALL BUTTON
            try
            {
                if (!Installer.IsInstalled)
                {
                    if (!Wow.IsAdministrator)
                    {
                        MessageBox.Show("Please run the Elophant Client as the Administrator to install it.");
                        Process.GetCurrentProcess().Kill();
                        return;
                    }
                    try
                    {
                        Installer.Install();
                    }
                    catch (UnauthorizedAccessException uaex)
                    {
                        MessageBox.Show("Unable to fully install/uninstall. Make sure LoL is not running.");
                        StaticLogger.Warning(uaex);
                    }
                    //InstallButton.Text = Installer.IsInstalled ? "Uninstall" : "Install";
                    UpdateStatus();
                }
            }
            catch
            {
            }

            TryToCheckForUpdates();
        }