c#读写注册表示例分享
时间:2022-06-26 13:08:45
//写注册表
RegistryKey regWrite;
//往HKEY_CURRENT_USER主键里的Software子键下写一个名为“Test”的子键
//如果Test子键已经存在系统会自动覆盖它
regWrite = Registry.CurrentUser.CreateSubKey("Software\\Test");
//往Test子键里添两条数据项,一条名为"Name",另一条名为"Sex"
//值分别是"luolie","男"
regWrite.SetValue("Name","luolie");
regWrite.SetValue("Sex","男");
//关闭该对象
regWrite.Close();
//读注册表
RegistryKey regRead;
//读取HKEY_CURRENT_USER主键里的Software子键下名为“Test”的子键
regRead= Registry.CurrentUser.OpenSubKey("Software\\Test",true);
if(regRead==null) //如果该子键不存在
{
MessageBox.Show("No Data!");
}
else
{
object obj= regRead.GetValue("Name"); //读取“Name”项的值
textBox1.Text = obj.ToString(); //显示在TextBox里
}
//关闭该对象
oReg.Close();
标签:读写注册表
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Opencv EigenFace人脸识别算法详解
2023-07-21 19:30:17
![](https://img.aspxhome.com/file/2023/5/101075_0s.png)
mybatis if标签判断不生效的解决方法
2023-11-28 12:30:49
Java 多线程并发LockSupport
2022-04-07 23:59:57
![](https://img.aspxhome.com/file/2023/5/91535_0s.png)
解决bufferedReader.readLine()读到最后发生阻塞的问题
2022-07-15 06:05:38
java垃圾回收原理之GC算法基础
2023-10-05 16:10:09
![](https://img.aspxhome.com/file/2023/2/87352_0s.png)
Java @Accessors注解图文详解
2023-10-10 06:06:51
![](https://img.aspxhome.com/file/2023/2/73072_0s.png)
c#入门之分支语句使用方法(三元运算符、if语句、switch语句)
2021-12-06 00:55:20
seata springcloud整合教程与遇到的坑
2023-09-19 03:11:06
Java对象不使用时赋值null的意义详解
2023-11-25 01:46:20
![](https://img.aspxhome.com/file/2023/4/59884_0s.png)
关于java 图形验证码的解决方法
2023-08-09 15:21:19
Java编程将汉字转Unicode码代码示例
2023-11-09 17:33:39
了解Java虚拟机JVM的基本结构及JVM的内存溢出方式
2023-02-20 03:08:51
![](https://img.aspxhome.com/file/2023/8/63288_0s.png)
java简单实现斗地主发牌功能
2023-06-18 16:22:44
![](https://img.aspxhome.com/file/2023/6/57506_0s.jpg)
Java JUC中操作List安全类的集合案例
2022-10-28 11:09:31
![](https://img.aspxhome.com/file/2023/7/83437_0s.png)
Java中String、StringBuffer、StringBuilder的区别介绍
2023-11-20 18:31:32
Java实现简单酒店管理系统
2023-02-22 12:41:21
rocketmq如何修改存储路径
2022-08-20 08:00:57
![](https://img.aspxhome.com/file/2023/2/62692_0s.jpg)
Android 6.0 蓝牙搜索不到设备原因,MIUI权限申请机制方法
2021-07-31 01:20:06
springboot配置文件绑定实现解析
2022-06-07 23:32:38
![](https://img.aspxhome.com/file/2023/7/61917_0s.png)
java显示当前运行时的参数(java运行参数)
2023-09-07 10:03:22