如何操作注册表

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
//写注册表
RegistryKey regWrite;
//往HKEY_CURRENT_USER主键里的Software子键下写一个名为“Test”的子键
//如果Test子键已经存在系统会自动覆盖它
regWrite = Registry.CurrentUser.CreateSubKey("Software//Test");
//往Test子键里添两条数据项,一条名为"Name",另一条名为"Sex"
//值分别是"luolie","男"
regWrite.SetValue("Name","luolie");
regWrite.SetValue("Sex","男");
//关闭该对象
regWrite.Close();


读注册表
RegistryKey regRead;
//读取HKEY_CURRENT_USER主键里的Software子键下名为“Test”的子键
regRead= Registry.CurrentUser.OpenSubKey("Software//Test",true);
if(regRead==null) //如果该子键不存在
{
MessageBox.Show("No Data!");
}
else

object obj= regRead.GetValue("Name"); //读取“Name”项的值
textBox1.Text = obj.ToString(); //显示在TextBox里

//关闭该对象
oRe
11AJ5293W010bb.jpg
seover="window.status='正文--如何操作注册表';return true">
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
文章标签: textbox user object null
个人分类: .net
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭