需要接别人的BHO项目

发布于 2024-11-05 14:02:13 字数 2546 浏览 0 评论 0原文

我需要接手离开团队的某人的项目。

该项目涉及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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

相对绾红妆 2024-11-12 14:02:13
// 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,并且它就发生在下面。

// 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.

执手闯天涯 2024-11-12 14:02:13

我能够找出问题,并且能够使用 regsvr32 手动注册它。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文