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