c#怎么遍历注册表

时间:2022-09-05 09:02:28
c#怎么遍历整个注册表,找到某一个值,如:valuexj然后删除该值,谢谢,指点下

12 个解决方案

#1


把sql语句用到C#中,where条件来限制。就是用到了Sqld的知识

egg:
    string sql="delete from table名 where 字段=aluexj";
用ExctuNonQuece的方法(执行增删改-返回受影响的行数)
sqlcommand cmd=new  sqlcommand(sql,connection);
connetion.open();
int row =cmd.ExctuNonQuece();
connection.close();
if(row>0)
{
MessagesBox.show("成功");
}

#2


整个注册表分为

1.HKEY_CLASSES_ROOT
2.HKEY_CURRENT_USER
3.HKEY_LOCAL_MACHINE
4.HKEY_USERS
5.HKEY_CURRENT_CONFIG


怎么能用算法一个一个遍历找到valuexj的键值呢,用类SQL怎么能实现呢,不是太明白

#3


学习~

#4


RegistryKey rsg = Registry.LocalMachine; 
rsg= rsg.OpenSubKey(@""); 
Object val = rsg.GetValue("");
 
RegistryKey delKey = Registry.LocalMachine.OpenSubKey("", true);
delKey.DeleteValue("");
delKey.Close();

#5


RegistryKey delKey = Registry.LocalMachine.OpenSubKey("", true);
delKey.DeleteValue("");
delKey.Close();

其中的opensubkey是查找字键啊,说明一下,我要查找的那个值在LocalMachine下,但就不知道在那个字键下,想通过像注册表中的查找功能找出我想删除的那个值,然后删除掉

#6


引用 4 楼 wuyq11 的回复:
RegistryKey rsg = Registry.LocalMachine;
rsg= rsg.OpenSubKey(@"");
Object val = rsg.GetValue("");

RegistryKey delKey = Registry.LocalMachine.OpenSubKey("", true);
delKey.DeleteValue("");
delKe……


up

#7


如果我想删除值为"xj",但我不知道"xj"在哪个子键下,
请问按照wuyq11的意思是不是这样:


RegistryKey rsg = Registry.LocalMachine; 
rsg= rsg.OpenSubKey(@"xj"); 
Object val = rsg.GetValue("xj");

RegistryKey delKey = Registry.LocalMachine.OpenSubKey("xj", true);
delKey.DeleteValue("xj");
delKey.Close();

#8


       学习..

#9


mark 以下~~~~~~~~~~~~~~~~~~~~~

#10


mark............

#11


.net源代码还原
QQ:9 282748 75
   本团队提供.net源代码还原,后期处理,你只要提供.net程序,我们帮你完完全全的还原成 aspx+cs,工程包运行起来,源码完整无错,绝对是你做项目的帮手,
反编时间短,成果立即可现
为你大大节约开发周期
欢迎与我联系

   资深的专家,为你节省时间,成本,项目当天或是几小时内便可以完成,做一个项目要花多少时间,要花多少费用,别人做好的,为何你还在苦苦开发!
  还等什么呢,时间就是金钱

修改时间在两天内即可完成,快的一天就可改好

电话:
 13672400434
邮箱:kbsi_skbcc@sina.com

#12


关注…以前有做过…现在忘咯

#1


把sql语句用到C#中,where条件来限制。就是用到了Sqld的知识

egg:
    string sql="delete from table名 where 字段=aluexj";
用ExctuNonQuece的方法(执行增删改-返回受影响的行数)
sqlcommand cmd=new  sqlcommand(sql,connection);
connetion.open();
int row =cmd.ExctuNonQuece();
connection.close();
if(row>0)
{
MessagesBox.show("成功");
}

#2


整个注册表分为

1.HKEY_CLASSES_ROOT
2.HKEY_CURRENT_USER
3.HKEY_LOCAL_MACHINE
4.HKEY_USERS
5.HKEY_CURRENT_CONFIG


怎么能用算法一个一个遍历找到valuexj的键值呢,用类SQL怎么能实现呢,不是太明白

#3


学习~

#4


RegistryKey rsg = Registry.LocalMachine; 
rsg= rsg.OpenSubKey(@""); 
Object val = rsg.GetValue("");
 
RegistryKey delKey = Registry.LocalMachine.OpenSubKey("", true);
delKey.DeleteValue("");
delKey.Close();

#5


RegistryKey delKey = Registry.LocalMachine.OpenSubKey("", true);
delKey.DeleteValue("");
delKey.Close();

其中的opensubkey是查找字键啊,说明一下,我要查找的那个值在LocalMachine下,但就不知道在那个字键下,想通过像注册表中的查找功能找出我想删除的那个值,然后删除掉

#6


引用 4 楼 wuyq11 的回复:
RegistryKey rsg = Registry.LocalMachine;
rsg= rsg.OpenSubKey(@"");
Object val = rsg.GetValue("");

RegistryKey delKey = Registry.LocalMachine.OpenSubKey("", true);
delKey.DeleteValue("");
delKe……


up

#7


如果我想删除值为"xj",但我不知道"xj"在哪个子键下,
请问按照wuyq11的意思是不是这样:


RegistryKey rsg = Registry.LocalMachine; 
rsg= rsg.OpenSubKey(@"xj"); 
Object val = rsg.GetValue("xj");

RegistryKey delKey = Registry.LocalMachine.OpenSubKey("xj", true);
delKey.DeleteValue("xj");
delKey.Close();

#8


       学习..

#9


mark 以下~~~~~~~~~~~~~~~~~~~~~

#10


mark............

#11


.net源代码还原
QQ:9 282748 75
   本团队提供.net源代码还原,后期处理,你只要提供.net程序,我们帮你完完全全的还原成 aspx+cs,工程包运行起来,源码完整无错,绝对是你做项目的帮手,
反编时间短,成果立即可现
为你大大节约开发周期
欢迎与我联系

   资深的专家,为你节省时间,成本,项目当天或是几小时内便可以完成,做一个项目要花多少时间,要花多少费用,别人做好的,为何你还在苦苦开发!
  还等什么呢,时间就是金钱

修改时间在两天内即可完成,快的一天就可改好

电话:
 13672400434
邮箱:kbsi_skbcc@sina.com

#12


关注…以前有做过…现在忘咯