需要采取别人的BHO项目

时间:2011-05-04 10:03:10

标签: internet-explorer bho

我需要接受一个离开团队的人的项目。

该项目涉及IE扩展开发。

我编译的项目没有.vdproj

众所周知,该项目可以正常编译,并将自己注册为Internet Explorer作为扩展名。

然而,给我的文件虽然编译得很好,却无法将自己注册为Internet Explorer作为扩展。

在这种情况下需要做些什么?

//小鼠

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using SHDocVw;
using BandObjectLib;

namespace CustomFunction
{
/// <summary>
/// Registration:
/// This is a browser helper object, which is registered as a COM When we register the 
/// SearchBar.dll using the regasm command.
/// Loading:
/// This COM object loaded for each IE window. As a window is created, it creates its own copy of the BHO; 
/// and, when that window is closed, it destroys its copy of the BHO
/// Purpose of implementing this BHO:
/// It loads the toolbar when this BHO is instantiated.
/// Code Reference: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=509297&SiteID=1
/// </summary>
[ComVisible(true)]
[Guid("1D970ED5-3EDA-438d-BFFD-715931E2775B")]
[ClassInterface(ClassInterfaceType.None)]
public class InitToolbarBHO : IObjectWithSite
{
   #region Fields
   private InternetExplorer explorer;
   private const string BHOKeyName =        "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects";
   #endregion

   #region Com Register/UnRegister Methods
   /// <summary>
   /// Called, when IE browser starts.
   /// </summary>
   /// <param name="t"></param>
   [ComRegisterFunction]
   public static void RegisterBHO(Type t)
   {
       RegistryKey key = Registry.LocalMachine.OpenSubKey(BHOKeyName, true);
       if (key == null)
       {
           key = Registry.LocalMachine.CreateSubKey(BHOKeyName);
       }
       string guidString = t.GUID.ToString("B");
       RegistryKey bhoKey = key.OpenSubKey(guidString, true);

       if (bhoKey == null)
       {
           bhoKey = key.CreateSubKey(guidString);
       }

       // NoExplorer:dword = 1 prevents the BHO to be loaded by Explorer
       string _name = "NoExplorer";
       object _value = (object)1;
       bhoKey.SetValue(_name, _value);
       key.Close();
       bhoKey.Close();
   }

   /// <param name="t"></param>
   [ComUnregisterFunction]
   public static void UnregisterBHO(Type t)
   {
       RegistryKey key = Registry.LocalMachine.OpenSubKey(BHOKeyName, true);
       string guidString = t.GUID.ToString("B");
       if (key != null)
       {
           key.DeleteSubKey(guidString, false);
       }
   }
  #endregion

2 个答案:

答案 0 :(得分:-1)

// NoExplorer:dword = 1 prevents the BHO to be loaded by Explorer
       string _name = "NoExplorer";
       object _value = (object)1;
       bhoKey.SetValue(_name, _value);

可能有你的答案,就在那里有评论。 将_value设置为1会阻止加载BHO,它会发生在那里。

答案 1 :(得分:-2)

我能够找到问题,我可以使用regsvr32手动注册。

相关问题