读写注册表的封装
2009-04-07 07:45
387 查看
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace WriteInReg
{
public class WriteIntoReg
{
/// <summary>
/// 从注册表获取值
/// </summary>
/// <param name="strKey">键值</param>
/// <returns></returns>
public static string GetValueRegUserKey(string strKey)
{
string strValue = "";
try
{
string str = string.Format(@"SoftWare/FreshAir/" + strKey);
RegistryKey Reg = Registry.CurrentUser.CreateSubKey(str);
Reg = Registry.CurrentUser.OpenSubKey(str);
strValue = Reg.GetValue("UserKey", "Admin").ToString();
Reg.Close();
}
catch { }
return strValue;
}
/// <summary>
/// 保存到注册表
/// </summary>
/// <param name="strKey">键</param>
/// <param name="strValue">值</param>
public static void SavaValueRegUserKey(string strKey, string strValue)
{
try
{
string str = string.Format(@"SoftWare/FreshAir/" + strKey);
RegistryKey Reg = Registry.CurrentUser.CreateSubKey(str);
Reg.SetValue("UserKey", strValue);
Reg.Close();
}
catch { }
}
}
}
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace WriteInReg
{
public class WriteIntoReg
{
/// <summary>
/// 从注册表获取值
/// </summary>
/// <param name="strKey">键值</param>
/// <returns></returns>
public static string GetValueRegUserKey(string strKey)
{
string strValue = "";
try
{
string str = string.Format(@"SoftWare/FreshAir/" + strKey);
RegistryKey Reg = Registry.CurrentUser.CreateSubKey(str);
Reg = Registry.CurrentUser.OpenSubKey(str);
strValue = Reg.GetValue("UserKey", "Admin").ToString();
Reg.Close();
}
catch { }
return strValue;
}
/// <summary>
/// 保存到注册表
/// </summary>
/// <param name="strKey">键</param>
/// <param name="strValue">值</param>
public static void SavaValueRegUserKey(string strKey, string strValue)
{
try
{
string str = string.Format(@"SoftWare/FreshAir/" + strKey);
RegistryKey Reg = Registry.CurrentUser.CreateSubKey(str);
Reg.SetValue("UserKey", strValue);
Reg.Close();
}
catch { }
}
}
}
相关文章推荐
- C#对注册表读写类的再封装
- C#对注册表读写类的再封装
- VC读写注册表
- VC 读写注册表
- java读写windows注册表
- C#操作注册表(读写)
- 配置文件与注册表的读写
- 读写注册表 registrykey 创建删除
- C# 32位/64位系统下程序读写注册表之差异
- ConfigurationPattern V1.1.1 版本发布--该版本增加自动读写注册表配置的功能
- Qt读写注册表和ini文件
- VB中如何实现注册表的读写
- (转)txt读写 操作封装
- (ZT)javascript取得机器名,用户名,读写注册表,启动应用程序
- Epoll-ET模式读写之用户连接的封装
- VC与EVC注册表读写操作对比
- 7、注册表读写的一个例子
- DELPHI注册表读写,含创建子键
- Windows读写注册表的例子
- C#操作注册表类(完整版,封装了各种方法只要调用即可)