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 Ex06_9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RegistryKey rgK = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
                              //当键值名为“NoDeskTop”的键值修改为“1”，则实现桌面图标的隐藏
            rgK.SetValue("NoDeskTop", 1, RegistryValueKind.DWord);
            MessageBox.Show(this, "成功隐藏桌面图标！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RegistryKey rgK = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
            rgK.SetValue("NoDeskTop", 0, RegistryValueKind.DWord);
            MessageBox.Show(this, "成功显示桌面图标！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            byte[] bvalues = new byte[] { 04, 00, 00, 00 };   
            RegistryKey rgK = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
                 //当键值名为“NoDrives”的键值修改为“ 04, 00, 00, 00 ”，则实现C盘的隐藏
            rgK.SetValue("NoDrives", bvalues, RegistryValueKind.Binary);
            MessageBox.Show(this, "成功隐藏了C盘！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            byte[] bvalues = new byte[] { 00, 00, 00, 00 };
            RegistryKey rgK = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
                 //当键值名为“NoDrives”的键值修改为“ 00, 00, 00, 00 ”，则实现所有驱动器的显示
            rgK.SetValue("NoDrives", bvalues, RegistryValueKind.Binary);
            MessageBox.Show(this, "显示所有磁盘！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
