0
点赞
收藏
分享

微信扫一扫

C#编程-144:通过注册表修改IE主页_彭世瑜_新浪博客

曾宝月 2022-04-02 阅读 43

C#编程-144:通过注册表修改IE主页_彭世瑜_新浪博客_winform​​



  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Microsoft.Win32;
  10. namespace IEIconShowTest
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. //显示桌面IE图标
  19. private void btnShow_Click(object sender, EventArgs e)
  20. {
  21. //完整路径:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel
  22. RegistryKey hkcu = Registry.CurrentUser;
  23. RegistryKey IEIcon = hkcu.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", true);
  24. IEIcon.SetValue("B416D21B-3B22-B6D4-BBD3-BBD452DB3D5B", 0);
  25. MessageBox.Show("设置成功,刷新显示");
  26. }
  27. //隐藏桌面IE图标
  28. private void btnHide_Click(object sender, EventArgs e)
  29. {
  30. RegistryKey hkcu = Registry.CurrentUser;
  31. RegistryKey IEIcon = hkcu.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", true);
  32. IEIcon.SetValue("B416D21B-3B22-B6D4-BBD3-BBD452DB3D5B", 1);
  33. MessageBox.Show("设置成功,刷新显示");
  34. }
  35. //设置IE主页
  36. private void btnSetup_Click(object sender, EventArgs e)
  37. {
  38. //完整路径:
  39. //HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
  40. //HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main
  41. string homePage = "http://www.baidu.com";
  42. RegistryKey hkcu = Registry.CurrentUser;
  43. RegistryKey homePage1 = hkcu.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true);
  44. RegistryKey hklm = Registry.LocalMachine;
  45. RegistryKey homePage2 = hklm.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main", true);
  46. if (txtHome.Text != "")
  47. {
  48. homePage1.SetValue("StartPage", homePage);
  49. homePage2.SetValue("StartPage", homePage);
  50. MessageBox.Show("设定成功:" + homePage);
  51. }
  52. else
  53. MessageBox.Show("请先输入正确的网址!");
  54. {
  55. }
  56. }
  57. }
  58. }


C#编程-144:通过注册表修改IE主页_彭世瑜_新浪博客_wpf_02​​



C#编程-144:通过注册表修改IE主页_彭世瑜_新浪博客_winform_03​​



C#编程-144:通过注册表修改IE主页_彭世瑜_新浪博客_windows_04​​



C#编程-144:通过注册表修改IE主页_彭世瑜_新浪博客_winform_05​​




举报

相关推荐

0 条评论