开发者

Need to take somebody's else BHO project

I need to take up somebody's project who left the team.

The project relates to IE extension development.

The project I was given compiled was without .vdproj

The project is known to compile fine and register itself with internet explorer as extension.

However the files given to me, although they compile fine, are not able to register itself with internet explorer as an extension.

What needs to be done in this case?

//mouse

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)
  开发者_C百科 {
       RegistryKey key = Registry.LocalMachine.OpenSubKey(BHOKeyName, true);
       string guidString = t.GUID.ToString("B");
       if (key != null)
       {
           key.DeleteSubKey(guidString, false);
       }
   }
  #endregion


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

there's probably your answer, right there with the comments. setting _value to 1 prevents the BHO to be loaded, and it happens right below there.


i was able to find out the problem, and i was able to register it manually using regsvr32.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜