C# 怎样修改默认的浏览器以及恢复?~~

解决方案 »

  1.   

    修改注册表,具体方法:
      1、开始→运行→输入regedit,打开注册表编辑器
      2、找到HKEY_CLASSES_ROOT\http\shell\open\command,在右边的窗口中双击"默认",将要用浏览器的可执行文件的完全路径输入到这里,例如设置IE为默认浏览器:输入“C:\Program Files\Internet Explorer\iexplore.exe”
      3、然后找到 HKEY_CLASSES_ROOT\http\shell\open\ddeexec\Application,在右边的窗口中双击"默认",设置浏览器名,如果是Firefox则输入Firefox,如果是IE则输入IExplore。(小提示:切记不能写错名称,如果你不知道浏览器的标准名称是什么,只需要到安装目录下查看该浏览器的名称即可)编程实现,可以参考下面这个修改注册启动程序的方法:
    /// <summary>
    /// 确定 按钮 事件(是否设置为开机自动启动)
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void Button4_Click(object sender, EventArgs e)
    {
    if (autoCheck.Checked == true)
    {
    //获取程序执行路径..
    string starupPath = Application.ExecutablePath;
    //class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
    RegistryKey loca = Registry.LocalMachine;
    RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");try
    {
    //SetValue:存储值的名称
    run.SetValue("qidong", starupPath);
    /// MessageBox.Show("已启用开机运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    loca.Close();
    }
    catch (Exception ee)
    {
    MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }}
    else
    {// MessageBox.Show("没有选中");
    //获取程序执行路径..
    string starupPath = Application.ExecutablePath;
    //class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
    RegistryKey loca = Registry.LocalMachine;
    RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");try
    {
    //SetValue:存储值的名称
    run.DeleteValue("qidong");
    MessageBox.Show("已停止开机运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    loca.Close();
    }
    catch (Exception ee)
    {
    MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }}
    }
      

  2.   

    lz应该是要通过C#设置默认浏览器,通过注册表就可以了
    HKEY_CLASSES_ROOT\http\shell\open\command
    3楼就可以了~
      

  3.   

    C#利用WebBrowser获取浏览器并设置默认浏览器的详解
      

  4.   

    C#利用WebBrowser获取浏览器并设置默认浏览器的详解