C#读取和写入注册表
2014-06-05 18:09
281 查看
RegistryKey hklm = Microsoft.Win32.Registry.LocalMachine;
RegistryKey hkSoftware = hklm.OpenSubKey("Software");
//只读
//RegistryKey hkMicrosoft = hkSoftware.OpenSubKey("Microsoft");
//可以写入
RegistryKey hkMicrosoft = hkSoftware.OpenSubKey("Microsoft",true);
//如果这个键以及存在,则返回RegistryKey事例,否则创建这个键
RegistryKey hkkey = hkMicrosoft.CreateSubKey("demo");
//写入
hkkey.SetValue("StringValue", "hello");
hkkey.SetValue("IntValue", 20);
//读取
string stringValue = hkkey.GetValue("StringValue").ToString();
int intValue = Convert.ToInt32(hkkey.GetValue("IntValue"));
//完成读取或者修改数据后,关闭键
hkkey.Close();
RegistryKey hkSoftware = hklm.OpenSubKey("Software");
//只读
//RegistryKey hkMicrosoft = hkSoftware.OpenSubKey("Microsoft");
//可以写入
RegistryKey hkMicrosoft = hkSoftware.OpenSubKey("Microsoft",true);
//如果这个键以及存在,则返回RegistryKey事例,否则创建这个键
RegistryKey hkkey = hkMicrosoft.CreateSubKey("demo");
//写入
hkkey.SetValue("StringValue", "hello");
hkkey.SetValue("IntValue", 20);
//读取
string stringValue = hkkey.GetValue("StringValue").ToString();
int intValue = Convert.ToInt32(hkkey.GetValue("IntValue"));
//完成读取或者修改数据后,关闭键
hkkey.Close();
相关文章推荐
- 关于C# 读取 写入 删除 注册表简单例子
- C# 操作注册表 写入注册表 修改注册表 读取注册表
- C# 操作注册表 写入注册表 修改注册表 读取注册表
- c#写入注册表,读取注册表。使用二进制数据
- c#大文件读取和写入数据库(带进度条的源代码)
- C#中的文件操作(读取文件与写入文件)
- 用C#读取Windows注册表中的多重字串和二进制字串
- c#大文件读取和写入数据库
- asp.net(c#)如何读取上传过程中的.txt文件中的数据,并将其写入数据库的
- 用C#读取Windows注册表中的多重字串和二进制字串开发者在线 Builder.com.cn 更新时间:2008-07-20作者: 来源:
- C#读取和写入Excel2003的代码
- C#对Oracle BLOB字段的写入读取方法
- C#操作Excel文件(读取Excel,写入Excel)
- C# StreamReader 和 StreamWriter 读取和写入汉字出现乱码的解决方法。
- 使用C#如何写入/读取注册表信息
- C#中的文件操作(读取文件与写入文件)
- cell中遍历读取数据并写入数据库(c#)
- ASP.NET读取和写入注册表
- C#创建、打开、读取、写入、保存Excel,Excel打印输出
- C#中,用注册表存储和读取信息