/// <summary>
/// 获取注册表的字符类型
/// </summary>
/// <param name="strPath">注册表路径</param>
/// <param name="strKey">注册表键</param>
/// <param name="strValue">键值</param>
/// <returns></returns>
static public string RegReadString(string strPath,string strKey)
{
RegistryKey key = null;
string strValue = "";
try
{
key = Registry.LocalMachine.OpenSubKey(strPath, false);
strValue = key.GetValue(strKey).ToString();
}
catch
{
key.Close();
return strValue;
}
key.Close();
return strValue;
}
/// <summary>
/// 向注册表写入字符键值
/// </summary>
/// <param name="strPath">注册表路径</param>
/// <param name="strKey">注册表键</param>
/// <param name="strValue">键值</param>
/// <returns></returns>
static public bool RegWriteString(string strPath, string strKey,string strValue)
{
RegistryKey key = null;
try
{
key = Registry.LocalMachine.OpenSubKey(strPath, true);
key.SetValue(strKey, strValue);
}
catch
{
key.Close();
return false;
}
key.Close();
return true;
}
/// 获取注册表的字符类型
/// </summary>
/// <param name="strPath">注册表路径</param>
/// <param name="strKey">注册表键</param>
/// <param name="strValue">键值</param>
/// <returns></returns>
static public string RegReadString(string strPath,string strKey)
{
RegistryKey key = null;
string strValue = "";
try
{
key = Registry.LocalMachine.OpenSubKey(strPath, false);
strValue = key.GetValue(strKey).ToString();
}
catch
{
key.Close();
return strValue;
}
key.Close();
return strValue;
}
/// <summary>
/// 向注册表写入字符键值
/// </summary>
/// <param name="strPath">注册表路径</param>
/// <param name="strKey">注册表键</param>
/// <param name="strValue">键值</param>
/// <returns></returns>
static public bool RegWriteString(string strPath, string strKey,string strValue)
{
RegistryKey key = null;
try
{
key = Registry.LocalMachine.OpenSubKey(strPath, true);
key.SetValue(strKey, strValue);
}
catch
{
key.Close();
return false;
}
key.Close();
return true;
}