using Microsoft.Win32; using System; using System.Text; namespace CapaDeNegocio { public class ClavesDeRegistroClase { public string GetRegKeys(string clave, string valClave, string ValueClave) { string _GetRegKeys = ""; try { RegistryKey SOFTWARE = Registry.CurrentUser.OpenSubKey("SOFTWARE", true); try { RegistryKey DIIISS = SOFTWARE.OpenSubKey("DIIISS", true); if (DIIISS == null) { DIIISS = SOFTWARE.CreateSubKey("DIIISS", true); } try { RegistryKey GMT = DIIISS.OpenSubKey("GMT", true); if (GMT == null) { GMT = DIIISS.CreateSubKey("GMT", true); } try { RegistryKey SisAdmin = GMT.OpenSubKey("SisAdmin", true); if (SisAdmin == null) { SisAdmin = GMT.CreateSubKey("SisAdmin", true); } try { RegistryKey Xclave = SisAdmin.OpenSubKey(clave, true); if (Xclave == null) { Xclave = SisAdmin.CreateSubKey(clave, true); } if (ValueClave != "") { Xclave.SetValue(valClave, ValueClave); } _GetRegKeys = Xclave.GetValue(valClave) == null? "":Xclave.GetValue(valClave).ToString(); Xclave.Close(); } catch { RegistryKey Xclave = SisAdmin.CreateSubKey(clave, true); } SisAdmin.Close(); } catch { RegistryKey SisAdmin = GMT.CreateSubKey("SisAdmin", true); } GMT.Close(); } catch { RegistryKey GMT = DIIISS.CreateSubKey("GMT", true); } DIIISS.Close(); } catch { RegistryKey DIIISS = SOFTWARE.CreateSubKey("DIIISS",true); } SOFTWARE.Close(); } catch { RegistryKey SOFTWARE = Registry.CurrentUser.CreateSubKey("SOFTWARE"); } return _GetRegKeys; } } }