需要接别人的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
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
评论里可能就有你的答案。
将 _value 设置为 1 会阻止加载 BHO,并且它就发生在下面。
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.
我能够找出问题,并且能够使用 regsvr32 手动注册它。
i was able to find out the problem, and i was able to register it manually using regsvr32.