zoukankan      html  css  js  c++  java
  • C#中访问注册表

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.Win32;

    namespace MyReg
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void btnCancel_Click(object sender, EventArgs e)
            {
                Close();
            }

            private void btnOK_Click(object sender, EventArgs e)
            {
                RegistryKey pregkey;
                pregkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true);
                pregkey.SetValue("DefaultUserName", "dongjichao");
               
                pregkey.SetValue("DefaultPassword", "");
                if (rdLogin.Checked)
                { pregkey.SetValue("AutoAdminLogon", "1");}
                else
                { pregkey.SetValue("AutoAdminLogon", "0");}
                pregkey.Close();
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                RegistryKey pregkey;
                string strkeyValue = "";
                pregkey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true);
                strkeyValue =pregkey.GetValue("AutoAdminLogon").ToString();
                if (strkeyValue!="")
                {
                    if (strkeyValue=="1")
                    {
                        rdLogin.Checked =true;
                        rdNoLogin.Checked =false;
                    }
                    else
                    {
                        rdLogin.Checked =false;
                        rdNoLogin.Checked =true;
                    }
                }
                pregkey.Close();
            }
        }
    }

  • 相关阅读:
    取消Win10自动更新?
    Mybatis入门调试错误:Could not find resource XXX
    IDEA导入新Module出现的问题
    WEB-INF目录下的存放包的目录只能命名为lib
    rocketmq 同步刷盘、异步刷盘和同步复制、异步复制
    spring 集成mybatis
    Spring <aop:aspectj-autoproxy proxy-target-class="false|true"/>
    spring中expose-proxy的作用与原理
    分布式事物
    <context:annotation-config/>,<mvc:annotation-driven/>和<context:component-scan>之间的关联
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2033131.html
Copyright © 2011-2022 走看看