实现效果:
知识运用:
Registry类的CurrentConfig字段 //包含有关用户特定的硬件的配置信息
RegistryKey类的GetSubKeyNames方法 //获取指定项包含的所有子项的名称
实现代码:
private void Form1_Load(object sender, EventArgs e) { this.TVRegedit.Nodes.Clear(); //清空所有树节点 RegistryKey rKey = Registry.CurrentConfig; //读取HKEY_CURRENT_CONFIG基项 TreeNode Tnode = new TreeNode("HKEY_CURRENT_CONFIG");//创建树节点 foreach (string s in rKey.GetSubKeyNames()) //遍历基项下的子项 { Tnode.Nodes.Add(s); //添加到基项节点 } TVRegedit.Nodes.Add(Tnode); //添加到控件进行显示 }