using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Win32;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
ListBox1.Items.Clear();
RegistryKey rk = Registry.LocalMachine;//选择读取HKEY_LOCAL_MACHINE主键信息
RegistryKey sys = rk.OpenSubKey("SYSTEM");//打开"SYSTEM"子键
RegistryKey co001 = sys.OpenSubKey("ControlSet001");//打开"ControlSet001"子键
RegistryKey co = co001.OpenSubKey("Control");//打开"Control"子键
foreach (string si in co.GetSubKeyNames())//开始遍历由子键名称组成的字符串数组
{
ListBox1.Items.Add(si);//在列表中添加子键名称
RegistryKey sikey = co.OpenSubKey(si);//打开子键
foreach (string sVName in sikey.GetValueNames())//开始遍历由指定子键拥有的键值名称组成的字符串数组
{
ListBox1.Items.Add("" + sVName + ": " + sikey.GetValue(sVName));//在列表中加入键名称和对应的键值
}
}
}
}
|