Пример #1
0
        private void ReOrderTree(RegistryKey regKey)
        {
            bool DidItWork = false;

            // foreach account login saved, add to dropbox
            if (regKey != null)
            {
                foreach (string InReg in regKey.GetSubKeyNames())
                {
                    if (InReg != null)
                    {
                        // Original Reg Key
                        RegistryKey Original = regKey;
                        // String 1
                        string initial = InReg.ToString();
                        // String 2
                        string tmp_adder = regKey.OpenSubKey(InReg.ToString()).GetValue("username").ToString();
                        tmp_adder = Dec(tmp_adder);
                        if (tmp_adder.Length > 0)
                        {
                            string tmp_origin = tmp_adder.Substring(tmp_adder.IndexOf("@") + 1);
                            tmp_adder = tmp_adder.Substring(0, tmp_adder.IndexOf("@"));
                            // Compare
                            if (InReg.ToString() == (tmp_adder + " (" + tmp_origin + ") "))
                            {
                                if (!metroComboBox1.Items.Contains(tmp_adder + " (" + tmp_origin + ") "))
                                {
                                    metroComboBox1.Items.Add(tmp_adder + " (" + tmp_origin + ") ");
                                }
                            }
                            else // Convert if old then add
                            {
                                // Conversion
                                RegistryKey tmpkey = regKey;
                                tmpkey = tmpkey.OpenSubKey(InReg);
                                RenameSubKey(regKey, InReg.ToString(), tmp_adder + " (" + tmp_origin + ") ");
                                // Add
                                DidItWork = true;
                            }
                        }
                    }
                }
            }
            // Restart to Add
            if (DidItWork)
            {
                ReOrderTree(regKey);
            }
        }
Пример #2
0
        public Splash1()
        {
            // Initialize Form
            InitializeComponent();
            try
            {
                // Get Unique SALT
                SALT = Security.FingerPrint.Value();
                SALT = StringToHex(SALT);
                // Create unexistant registry key
                RegistryKey regKey = Registry.LocalMachine;
                if (regKey.OpenSubKey(@"SOFTWARE\BnS Buddy\") == null)
                {
                    Registry.LocalMachine.CreateSubKey("SOFTWARE\\BnS Buddy");
                }
                // Check if not already remembered
                if (File.ReadAllText(@AppPath + "\\Settings.ini").Contains("rememberme = true"))
                {
                    metroComboBox1.Enabled = true;
                    regKey = Registry.LocalMachine;
                    regKey = regKey.OpenSubKey(@"SOFTWARE\BnS Buddy\", true);

                    // foreach account login saved, add to dropbox
                    foreach (string InReg in regKey.GetSubKeyNames())
                    {
                        metroComboBox1.Items.Add(InReg.ToString());
                    }

                    if (metroComboBox1.Items.Count >= 1)
                    {
                        // Select first found
                        metroComboBox1.SelectedIndex = 0;

                        // Select last used
                        if (regKey != null)
                        {
                            if (regKey.GetValue("lastused") != null)
                            {
                                string tmp_last = string.Empty;
                                tmp_last = regKey.GetValue("lastused").ToString();
                                if (tmp_last != null)
                                {
                                    if (tmp_last.Length > 1)
                                    {
                                        metroComboBox1.SelectedIndex = metroComboBox1.FindStringExact(tmp_last);
                                        metroButton3.Visible         = true;
                                    }
                                }
                            }
                        }

                        string tmp_user = string.Empty;
                        string tmp_pass = string.Empty;
                        if (regKey != null)
                        {
                            tmp_user                  = regKey.OpenSubKey(metroComboBox1.SelectedItem.ToString()).GetValue("username").ToString();
                            tmp_pass                  = regKey.OpenSubKey(metroComboBox1.SelectedItem.ToString()).GetValue("password").ToString();
                            metroTextBox1.Text        = Dec(tmp_user);
                            metroTextBox2.Text        = Dec(tmp_pass);
                            metroCheckBox1.CheckState = CheckState.Checked;
                            metroButton3.Visible      = true;
                        }
                    }
                }

                // Check caps lock
                CheckLock();
            } catch { Prompt.Popup("Unknown Error Occured: Resetted Registry."); ClearRegistry(); }
        }
Пример #3
0
        public void ClearRegistry()
        {
            RegistryKey regKey = Registry.LocalMachine;

            regKey = regKey.OpenSubKey(@"SOFTWARE\BnS Buddy\", true);
            foreach (string InReg in regKey.GetSubKeyNames())
            {
                Registry.LocalMachine.OpenSubKey("SOFTWARE\\BnS Buddy", true).DeleteSubKeyTree(InReg.ToString());
            }
            regKey.DeleteValue("lastused");
        }