?? form1.cs
字號:
?using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Diagnostics;
namespace 修改注冊表
{
public partial class Form1 : Form
{
RegistryKey key1;
RegistryKey key2;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
key1 = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2 = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
#region 顯示桌面
if ((int)key1.GetValue("NoDesktop", 0) == 0)
{
checkBox1.Checked = true;
}
else
{
checkBox1.Checked = false;
}
if ((int)key1.GetValue("NoNetHood", 0) == 0)
{
checkBox2.Checked = true;
}
else
{
checkBox2.Checked = false;
}
if ((int)key1.GetValue("NoViewContextMenu", 0) == 0)
{
checkBox3.Checked = true;
}
else
{
checkBox3.Checked = false;
}
if ((int)key1.GetValue("NoSaveSettings", 0) == 0)
{
checkBox4.Checked = true;
}
else
{
checkBox4.Checked = false;
}
#endregion
#region 開始菜單
if ((int)key1.GetValue("NoClose", 0) == 0)
{
checkBox5.Checked = true;
}
else
{
checkBox5.Checked = false;
}
if ((int)key1.GetValue("NoRun", 0) == 0)
{
checkBox6.Checked = true;
}
else
{
checkBox6.Checked = false;
}
if ((int)key1.GetValue("NoFind", 0) == 0)
{
checkBox7.Checked = true;
}
else
{
checkBox7.Checked = false;
}
if ((int)key1.GetValue("NoRecentDocsMenu", 0) == 0)
{
checkBox8.Checked = true;
}
else
{
checkBox8.Checked = false;
}
if ((int)key1.GetValue("NoWindowsUpdate", 0) == 0)
{
checkBox9.Checked = true;
}
else
{
checkBox9.Checked = false;
}
#endregion
#region 顯示屬性
if ((int)key2.GetValue("NoDispBackgroundPage", 0) == 0)
{
checkBox10.Checked = true;
}
else
{
checkBox10.Checked = false;
}
if ((int)key2.GetValue("NoDispScrsavPage", 0) == 0)
{
checkBox11.Checked = true;
}
else
{
checkBox11.Checked = false;
}
if ((int)key2.GetValue("NoDispAppearancePage", 0) == 0)
{
checkBox12.Checked = true;
}
else
{
checkBox12.Checked = false;
}
if ((int)key2.GetValue("NoDispSettingsPage", 0) == 0)
{
checkBox13.Checked = true;
}
else
{
checkBox13.Checked = false;
}
#endregion
}
/// <summary>
/// 刷新系統(tǒng)
/// </summary>
private void RefreshSystem()
{
Process[] process = Process.GetProcessesByName("explorer");
foreach (Process myProcess in process)
{
myProcess.Kill();
}
}
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1 .Checked )
{
key1.SetValue("NoDesktop", 0);
}
else
{
key1.SetValue("NoDesktop", 1);
}
if (checkBox2.Checked )
{
key1.SetValue("NoNetHood", 0);
}
else
{
key1.SetValue("NoNetHood", 1);
}
if (checkBox3 .Checked )
{
key1.SetValue("NoViewContextMenu", 0);
}
else
{
key1.SetValue("NoViewContextMenu", 1);
}
if (checkBox4 .Checked )
{
key1.SetValue("NoSaveSettings", 0);
}
else
{
key1.SetValue("NoSaveSettings", 1);
}
RefreshSystem();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
key1.Close();
key2.Close();
}
private void button3_Click(object sender, EventArgs e)
{
if (checkBox5 .Checked )
{
key1.SetValue("NoClose", 0);
}
else
{
key1.SetValue("NoClose", 1);
}
if (checkBox6 .Checked )
{
key1.SetValue("NoRun", 0);
}
else
{
key1.SetValue("NoRun", 1);
}
if (checkBox7 .Checked )
{
key1.SetValue("NoFind", 0);
}
else
{
key1.SetValue("NoFind", 1);
}
if (checkBox8 .Checked )
{
key1.SetValue("NoRecentDocsMenu", 0);
}
else
{
key1.SetValue("NoRecentDocsMenu", 1);
}
if (checkBox9 .Checked )
{
key1.SetValue("NoWindowsUpdate", 0);
}
else
{
key1.SetValue("NoWindowsUpdate", 1);
}
RefreshSystem();
}
private void button5_Click(object sender, EventArgs e)
{
if (checkBox10 .Checked )
{
key2.SetValue("NoDispBackgroundPage", 0);
}
else
{
key2.SetValue("NoDispBackgroundPage", 1);
}
if (checkBox11 .Checked )
{
key2.SetValue("NoDispScrsavPage", 0);
}
else
{
key2.SetValue("NoDispScrsavPage", 1);
}
if (checkBox12 .Checked )
{
key2.SetValue("NoDispAppearancePage", 0);
}
else
{
key2.SetValue("NoDispAppearancePage", 1);
}
if (checkBox13 .Checked )
{
key2.SetValue("NoDispSettingsPage", 0);
}
else
{
key2.SetValue("NoDispSettingsPage", 1);
}
RefreshSystem();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -