Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RegisteryManager
- {
- private string keyPath = (System.Environment.Is64BitOperatingSystem) ? Global.BolRegisteryx64path : Global.BolRegisteryx86path;
- private string username { get; set; }
- private string password { get; set; }
- public RegisteryManager()
- {
- string subkey = (System.Environment.Is64BitOperatingSystem) ? "SOFTWARE\\WOW6432Node" : "SOFTWARE" ;
- RegistryKey registeryKey = Registry.LocalMachine.OpenSubKey(subkey);
- if(registeryKey != null)
- {
- RegistryKey bolKey = registeryKey.OpenSubKey("BOL");
- if(bolKey == null)
- {
- registeryKey.CreateSubKey("BOL");
- bolKey = registeryKey.OpenSubKey("BOL", true);
- bolKey.SetValue(Global.BolRegisteryUsername, "default");
- bolKey.SetValue(Global.BolRegisteryPassword, "default");
- }
- }
- }
- public string ReadKey()
- {
- RegistryKey registeryKey = Registry.LocalMachine.OpenSubKey(this.keyPath);
- if(registeryKey != null)
- {
- String username = (String)registeryKey.GetValue(Global.BolRegisteryUsername);
- String password = (String)registeryKey.GetValue(Global.BolRegisteryPassword);
- if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
- {
- return String.Concat(username, "|", password);
- }
- }
- return String.Empty;
- }
- public void WriteKey(string key, string value)
- {
- RegistryKey registeryKey = Registry.LocalMachine.OpenSubKey(this.keyPath, true);
- if (registeryKey != null)
- {
- registeryKey.SetValue(key, value);
- }
- }
- public void EraseBolKeys()
- {
- string subkey = (System.Environment.Is64BitOperatingSystem) ? "SOFTWARE\\WOW6432Node" : "SOFTWARE";
- RegistryKey registeryKey = Registry.LocalMachine.OpenSubKey(subkey);
- if (registeryKey != null)
- {
- RegistryKey bolKey = registeryKey.OpenSubKey("BOL");
- if (bolKey != null)
- {
- bolKey = registeryKey.OpenSubKey("BOL", true);
- bolKey.SetValue(Global.BolRegisteryUsername, "default");
- bolKey.SetValue(Global.BolRegisteryPassword, "default");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment