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();
            }
        }
    }

  • 相关阅读:
    C#学习笔记之——矩形覆盖问题
    链表,栈,队列代码
    链表练习代码
    2012年全国计算机专业大学排名
    寄存器介绍
    win8 wifi开关显示关闭,且设置里面wifi开关显示灰色的解决办法
    360随身wifi无法使用临时解决方案大全
    锐捷客户端的校园网电脑如何转化成无线路由
    未完成数据结构题目
    数据结构代码1
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2033131.html
Copyright © 2011-2022 走看看