using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Win32; namespace Atesa.Utilitarios { public class ObtieneParametros { private string key = @"SOFTWARE\\Parametros"; public void AddValueKeyRegedit(string KeyStringName, string KeyStringValue, bool Encrypt) { try { RegistryKey key2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32).OpenSubKey(this.key, true); if (key2 != null) { if (Encrypt) { //key2.SetValue(KeyStringName, new Crypt().EncryptString(KeyStringValue), RegistryValueKind.String); } else { key2.SetValue(KeyStringName, KeyStringValue, RegistryValueKind.String); } } } catch { } } public Dictionary GetRegistrySubKeys() { Dictionary dictionary = new Dictionary(); using (RegistryKey key2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32).OpenSubKey(this.key)) { if (key2 == null) { return dictionary; } string[] valueNames = key2.GetValueNames(); foreach (string str in valueNames) { object obj2 = key2.GetValue(str); dictionary.Add(str, obj2); } key2.Close(); } return dictionary; } public string GetValueKeyRegedit(string KeyStringName, bool Decrypt) { string str = string.Empty; try { RegistryKey key2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32).OpenSubKey(this.key, false); if (key2 == null) { return str; } if (Decrypt) { //str = new Crypt().DecryptString(Convert.ToString(key2.GetValue(KeyStringName))); } else { str = Convert.ToString(key2.GetValue(KeyStringName)); } key2.Close(); } catch { } return str; } } }