直接给源码:
读取注册表内容:
RegistryKey regkey=Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
string[] n=regkey.GetValueNames();
for(int i=0;i<n.Length;i++)
{
Response.Write(n[i]+": "+regkey.GetValue(n[i])+"<br >");
}
写入注册表:
RegistryKey regkeySetKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true).CreateSubKey("test_test");
regkeySetKey.SetValue("Key1","Value1");
regkeySetKey.SetValue("Key2","Value2");
regkeySetKey.SetValue("Key3",3);