码迷,mamicode.com
首页 > 其他好文 > 详细

设置IE浏览器的默认主页

时间:2019-01-31 22:48:10      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:null   explore   get   textbox   浏览器   out   exp   pre   explorer   

实现效果:
  技术分享图片

知识运用:
  RegistryKey类的GetValue方法

  public Object GetValue (string name , Object defaultValue)

  name : 要检索的值的名称

  defaultValue: 在name不存在时返回的值 

实现代码:

        private void Form1_Load(object sender, EventArgs e)
        {
            RegistryKey regMain = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main");
            object DPage = regMain.GetValue("Start Page","没有值");
            textBox1.Text = DPage.ToString();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBox2.Text))
            {
                RegistryKey regMain = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main");
                regMain.SetValue("Start Page", textBox2.Text);
                MessageBox.Show("已设置主页为:"+textBox2.Text);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            RegistryKey regMain = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main");
            regMain.SetValue("Start Page", "about:blank");
            MessageBox.Show("已设置主页为:"+"空白页");
        }

 

设置IE浏览器的默认主页

标签:null   explore   get   textbox   浏览器   out   exp   pre   explorer   

原文地址:https://www.cnblogs.com/feiyucha/p/10344059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!