2018-06-08 19:11:02 +00:00
|
|
|
|
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
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2018-06-09 21:10:16 +00:00
|
|
|
|
private string key = @"SOFTWARE\\Parametros";
|
|
|
|
|
|
|
2018-06-26 22:55:14 +00:00
|
|
|
|
// public ObtieneParametros(string subkey = null)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// try
|
|
|
|
|
|
// {
|
|
|
|
|
|
// this.key = string.IsNullOrWhiteSpace(subkey) ? this.key : string.Format(@"{0}\{1}", this.key, subkey);
|
|
|
|
|
|
// RegistryKey key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32);
|
|
|
|
|
|
// if (key.OpenSubKey(this.key) == null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// key.CreateSubKey(this.key, RegistryKeyPermissionCheck.ReadWriteSubTree);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// catch
|
|
|
|
|
|
// {
|
|
|
|
|
|
// throw new Exception("The registry key 'ParametrosProceso' does not exist and could not create it");
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
2018-06-09 21:10:16 +00:00
|
|
|
|
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<string, object> GetRegistrySubKeys()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<string, object> dictionary = new Dictionary<string, object>();
|
|
|
|
|
|
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)
|
2018-06-08 19:11:02 +00:00
|
|
|
|
{
|
2018-06-09 21:10:16 +00:00
|
|
|
|
string str = string.Empty;
|
2018-06-08 19:11:02 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2018-06-09 21:10:16 +00:00
|
|
|
|
RegistryKey key2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32).OpenSubKey(this.key, false);
|
|
|
|
|
|
if (key2 == null)
|
2018-06-08 19:11:02 +00:00
|
|
|
|
{
|
2018-06-09 21:10:16 +00:00
|
|
|
|
return str;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Decrypt)
|
|
|
|
|
|
{
|
|
|
|
|
|
//str = new Crypt().DecryptString(Convert.ToString(key2.GetValue(KeyStringName)));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
str = Convert.ToString(key2.GetValue(KeyStringName));
|
|
|
|
|
|
}
|
|
|
|
|
|
key2.Close();
|
2018-06-08 19:11:02 +00:00
|
|
|
|
}
|
2018-06-09 21:10:16 +00:00
|
|
|
|
catch
|
2018-06-08 19:11:02 +00:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2018-06-09 21:10:16 +00:00
|
|
|
|
return str;
|
2018-06-08 19:11:02 +00:00
|
|
|
|
}
|
2018-06-09 21:10:16 +00:00
|
|
|
|
|
2018-06-08 19:11:02 +00:00
|
|
|
|
}
|
2018-06-09 21:10:16 +00:00
|
|
|
|
|
2018-06-08 19:11:02 +00:00
|
|
|
|
}
|
2018-06-09 21:10:16 +00:00
|
|
|
|
|