2011-05-04 33 views
-2

我需要接受某人離開球隊的項目。需要採取別人的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 
+0

BHO寫的是什麼語言?向我們展示一些代碼,因爲在這一點上我們知道的比你少。 另外; 自BHO寫入以來,IE API是否已更改? 在嘗試連接到IE時,您能否在調試過程中逐步瀏覽BHO? – 2011-05-04 10:10:34

+0

bho是用c#編寫的,自BHO寫入以來,API沒有改變。是的,我不知道我是否可以在調試模式下通過BHO。如何找到那個..雖然我知道,罰款到Internet Explorer沒有任何錯誤。至於代碼..讓我編輯原始文件 – debuggerpk 2011-05-04 10:32:35

+0

代碼更新..請看看 – debuggerpk 2011-05-04 10:42:17

回答

-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被加載,並且它發生在那裏。

+0

我以爲資源管理器和Internet Explorer是兩回事。將其設置爲0.並回報。 – debuggerpk 2011-05-04 11:37:36

+0

似乎是一個合乎邏輯的假設,你可能是對的,第二眼... – 2011-05-04 11:43:30

+0

將其設置爲0並不幫助 – debuggerpk 2011-05-04 11:45:14

-2

我能夠找出問題,我能夠使用regsvr32手動註冊它。

+2

除非你需要做的唯一事情是運行regsvr32,我認爲這是註冊它的正常方式,所以也許這就是你現在所沒有的......。如果你打算接受你的回答,至少要解釋你做了什麼,這可能會幫助別人。 – 2011-05-07 20:13:13