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 IEIconShowTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //显示桌面IE图标 private void btnShow_Click(object sender, EventArgs e) { //完整路径:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel RegistryKey hkcu = Registry.CurrentUser; RegistryKey IEIcon = hkcu.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", true); IEIcon.SetValue("B416D21B-3B22-B6D4-BBD3-BBD452DB3D5B", 0); MessageBox.Show("设置成功,刷新显示"); } //隐藏桌面IE图标 private void btnHide_Click(object sender, EventArgs e) { RegistryKey hkcu = Registry.CurrentUser; RegistryKey IEIcon = hkcu.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", true); IEIcon.SetValue("B416D21B-3B22-B6D4-BBD3-BBD452DB3D5B", 1); MessageBox.Show("设置成功,刷新显示"); } //设置IE主页 private void btnSetup_Click(object sender, EventArgs e) { //完整路径: //HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main //HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main string homePage = "http://www.baidu.com"; RegistryKey hkcu = Registry.CurrentUser; RegistryKey homePage1 = hkcu.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true); RegistryKey hklm = Registry.LocalMachine; RegistryKey homePage2 = hklm.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true); if (txtHome.Text != "") { homePage1.SetValue("StartPage", homePage); homePage2.SetValue("StartPage", homePage); MessageBox.Show("设定成功:" + homePage); } else MessageBox.Show("请先输入正确的网址!"); { } } } }