码迷,mamicode.com
首页 > Web开发 > 详细

ASP.NET中如何读取和写入注册表

时间:2014-12-22 15:54:54      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

直接给源码:

读取注册表内容:

1 RegistryKey regkey=Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
2 string[] n=regkey.GetValueNames();
3 for(int i=0;i<n.Length;i++)
4 {
5   Response.Write(n[i]+": "+regkey.GetValue(n[i])+"<br >");
6 }

 

写入注册表:

1 RegistryKey regkeySetKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true).CreateSubKey("test_test");   
2 regkeySetKey.SetValue("Key1","Value1");    
3 regkeySetKey.SetValue("Key2","Value2");    
4 regkeySetKey.SetValue("Key3",3);

 

ASP.NET中如何读取和写入注册表

标签:

原文地址:http://www.cnblogs.com/PiaoMiaoGongZi/p/4178234.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!