实现效果:
知识运用:
RegistryKey类的CreateSubKey和SetValue方法
实现代码:
private void button1_Click(object sender, EventArgs e) { RegistryKey rKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"); if (checkBox1.Checked) rKey.SetValue("{20D04FE0-3AEA-1069-A2D8-08002B30309D}",1); if (checkBox2.Checked) rKey.SetValue("{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}",1); //网上邻居 if (checkBox3.Checked) rKey.SetValue("{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", 1); //控制面板 if (checkBox4.Checked) rKey.SetValue("{59031a47-3f72-44a7-89c5-5595fe6b30ee}", 1); //我的文档 if (checkBox5.Checked) rKey.SetValue("{645FF040-5081-101B-9F08-00AA002F954E}", 1); MessageBox.Show("隐藏成功——请刷新桌面"); } private void button2_Click(object sender, EventArgs e) { RegistryKey rKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"); if (checkBox1.Checked) rKey.SetValue("{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0); if (checkBox2.Checked) rKey.SetValue("{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", 0); if (checkBox3.Checked) rKey.SetValue("{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", 0); if (checkBox4.Checked) rKey.SetValue("{59031a47-3f72-44a7-89c5-5595fe6b30ee}", 0); if (checkBox5.Checked) rKey.SetValue("{645FF040-5081-101B-9F08-00AA002F954E}", 0); MessageBox.Show("隐藏成功——请刷新桌面"); }