码迷,mamicode.com
首页 > Windows程序 > 详细

C# 注册表Regedit读写

时间:2016-08-28 22:27:31      阅读:660      评论:0      收藏:0      [点我收藏+]

标签:

注册表的读写

1、读

     public static string GetRegeditData()
        {
            //Win10 读写LocalMachine权限,没有访问权限
            RegistryKey hkml = Registry.CurrentUser;
            RegistryKey software = hkml.OpenSubKey("SOFTWARE", true);
            RegistryKey aimdir = software.OpenSubKey("EmailTool", true);
            if (aimdir==null)
            {
                return null;
            }
            object value = aimdir.GetValue("LastDate");
            return value==null?null:value.ToString();
        }

2、写

     public static bool CreateRegedit(string tovalue)
        {
            //Win10 读写LocalMachine权限,没有访问权限
            RegistryKey hklm = Registry.CurrentUser;
            RegistryKey software = hklm.OpenSubKey("SOFTWARE", true);
            RegistryKey aimdir = software.CreateSubKey("EmailTool");
            aimdir.SetValue("LastDate", tovalue);
            return true;
        }    

这只是简单的读写,提供给大家入门的方法。

 

C# 注册表Regedit读写

标签:

原文地址:http://www.cnblogs.com/kybs0/p/5816136.html

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