static void Main()
        {
            try
            {
                var res_man = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));

                int process = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length;
                if (process > 1)
                {
                    SetForegroundWindow(process);
                    MessageBox.Show(res_man.GetString("ProgramCheckBackRun", cul), res_man.GetString("ProgramCheckBackRun2", cul), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                // Ini Tool Settings -> IniToolSettings.cs
                IniToolSettings.InitilizeSettings();

                // Set DPI AWARE
                if (Environment.OSVersion.Version.Major >= 6)
                {
                    SetProcessDPIAware();
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Start();
            }
            catch (Exception ex)
            {
                Logs.DebugErrorLogs(ex);
                MessageBox.Show("Moto_Boot_Logo_Maker: Start up error: " + ex, "EXECUTING FATAL ERROR: Moto_Boot_Logo_Maker " + Logs.GetClassName(ex) + " " + Logs.GetLineNumber(ex), MessageBoxButtons.OK, MessageBoxIcon.Error);
                Kill.PanicKill();
                return;
            }
        }
Exemple #2
0
 public static void IFNOT48()
 {
     try
     {
         const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
         using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
         {
             int releaseKey = Convert.ToInt32(ndpKey.GetValue("Release"));
             if (ndpKey != null && ndpKey.GetValue("Release") != null)
             {
                 if (CheckFor48DotVersion(releaseKey) != "4.8")
                 {
                     MessageBox.Show(".NET Framework version does not match with v4.8! \nDebug Info: " + CheckFor48DotVersion(releaseKey), "Moto_Boot_Logo_Maker cannot be launched... .NET Framework troubles", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     Process.Start("https://dotnet.microsoft.com/download/dotnet-framework/net48");
                     Kill.PanicKillInternal();
                     return;
                 }
             }
             else
             {
                 if (CheckFor48DotVersion(releaseKey) != "4.8")
                 {
                     MessageBox.Show(".NET Framework error missig or lower than v4.8 \nDebug Info: " + CheckFor48DotVersion(releaseKey), "Moto_Boot_Logo_Maker cannot be launched... .NET Framework troubles", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     Process.Start("https://dotnet.microsoft.com/download/dotnet-framework/net48");
                     Kill.PanicKillInternal();
                     return;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(".NET Framework error" + ex.ToString(), "Moto_Boot_Logo_Maker cannot be launched... .NET Framework troubles", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Process.Start("https://dotnet.microsoft.com/download/dotnet-framework/net48");
         Kill.PanicKillInternal();
         return;
     }
 }
        public static void InitilizeSettings()
        {
            // Tool Initial Settings

            if (!Directory.Exists(exePath + @"\Logs\"))
            {
                Directory.CreateDirectory(exePath + @"\Logs\");
            }

            CheckNetFamework.IFNOT48();

            if (!Directory.Exists(exePath + @"\Settings\"))
            {
                Directory.CreateDirectory(exePath + @"\Settings\");
            }

            PortableSettingsProvider.SettingsFileName  = "Settings.config";
            PortableSettingsProvider.SettingsDirectory = "Settings\\";
            PortableSettingsProvider.ApplyProvider(Properties.Settings.Default);
            PortableSettingsProvider.ApplyProvider(Properties.Profiles.Default);

            var res_man = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));

            if (!OSVersionInfo.Name.Equals("Windows 10") && !OSVersionInfo.Name.Equals("Windows 8.1") && !OSVersionInfo.Name.Equals("Windows 8") && !OSVersionInfo.Name.Equals("Windows 7"))
            {
                CheckNetFamework.Get48FromRegistry();
                MessageBox.Show(res_man.GetString("ProgramCheckWindows", cul) + " " + OSVersionInfo.Name, res_man.GetString("ProgramCheckWindows2", cul), MessageBoxButtons.OK, MessageBoxIcon.Error);
                Kill.PanicKillInternal();
                return;
            }
            else
            {
                CheckNetFamework.Get48FromRegistry();
            }

            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            if (Properties.Settings.Default.ToolVersion == "")
            {
                if (Properties.Settings.Default.UpgradeRequired == true)
                {
                    Properties.Settings.Default.Upgrade();
                    Properties.Settings.Default.UpgradeRequired = false;
                }
                Properties.Settings.Default.ToolVersion = version;
                Properties.Settings.Default.Save();
            }

            if (version != Properties.Settings.Default.ToolVersion)
            {
                Properties.Settings.Default.ToolVersion = version;
                Properties.Settings.Default.Save();
            }

            if (CheckAdmin.IsUserAdministrator() == true)
            {
                Properties.Settings.Default.IsAdmin = true;
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.IsAdmin = false;
                Properties.Settings.Default.Save();
            }

            if (Properties.Settings.Default.LogoWasSaved == true)
            {
                Properties.Settings.Default.LogoWasSaved = false;
                Properties.Settings.Default.Save();
            }

            if (Properties.Settings.Default.LogoBinOpenSave == false)
            {
                Properties.Settings.Default.LogoWasSaved = false;
                Properties.Settings.Default.LogoBinOpen  = "";
                Properties.Settings.Default.Save();
            }

            string x86path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
            string x64path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

            if (exePath == x86path || exePath == x64path)
            {
                if (CheckAdmin.IsUserAdministrator() == false)
                {
                    MessageBox.Show(res_man.GetString("ProgramCheckPrivileges", cul), res_man.GetString("ProgramCheckPrivileges2", cul), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Kill.PanicKillInternal();
                    return;
                }
            }

            if (!Directory.Exists(exePath + @"\Files\"))
            {
                Directory.CreateDirectory(exePath + @"\Files\");
            }

            CreateDirectory(@"LogoZip");
            CreateDirectory(@"Images\Logo");
            CreateDirectory(@"Images\Icons");
            CreateDirectory(@"Bin");
            CreateDirectory(@"Bin\4MB");
            CreateDirectory(@"Bin\6MB");
            CreateDirectory(@"Bin\8MB");
            CreateDirectory(@"Bin\16MB");
            CreateDirectory(@"Bin\32MB");

            if (File.Exists(exePath + @"\Files\*.zip"))
            {
                File.Delete(exePath + @"\Files\*.zip");
            }

            if (File.Exists(exePath + @"\*.zip"))
            {
                File.Delete(exePath + @"\*.zip");
            }
        }