Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i write an add-on for internet explorer 11

i am already add guid variables

C#
[ComVisible(true), Guid("86524891-49EB-4F46-BAE3-C5545B81A671"), ClassInterface(ClassInterfaceType.None)]


and already add referances MSHTML and SHDocVw and already write ComRegister function, unregister function

C#
[ComRegisterFunction]
   public static void RegisterBHO(Type type)
   {
       RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);

       if (registryKey == null)
       {
           registryKey = Registry.LocalMachine.CreateSubKey(BHOKEYNAME);
       }
       string guid = type.GUID.ToString("B");
       RegistryKey ourKey = registryKey.OpenSubKey(guid);
       if (ourKey == null)
       {
           ourKey = registryKey.CreateSubKey(guid);
       }
       ourKey.SetValue("Alright", 1);
       registryKey.Close();
       ourKey.Close();
   }
[ComUnregisterFunction]
   public static void UnregisterBHO(Type type)
   {
       RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);
       string guid = type.GUID.ToString("B");

       if (registryKey != null)
       {
           registryKey.DeleteSubKey(guid, false);
       }
   }


and already write set / getsite functions

C#
public int SetSite([MarshalAs(UnmanagedType.IUnknown)] object site)
        {
        if (site != null)
        {
            webBrowser = (SHDocVw.WebBrowser)site;
            webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
            webBrowser.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
            webBrowser.NavigateComplete2 += WebBrowser_NavigateComplete2;
        }
        else
        {
            webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
            webBrowser.BeforeNavigate2 -= new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
            webBrowser.NavigateComplete2 -= WebBrowser_NavigateComplete2;
            webBrowser = null;
        }
        return 0;
    }
    private void WebBrowser_NavigateComplete2(object pDisp, ref object URL)
    {

    }
    public int GetSite(ref Guid guid, out IntPtr ppvSite)
        {
        IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
        int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
        Marshal.Release(punk);
        return hr;
    }


C#
i write an add-on for internet explorer 11

i am already add guid variables

 [ComVisible(true), Guid("86524891-49EB-4F46-BAE3-C5545B81A671"), ClassInterface(ClassInterfaceType.None)]
and already add referances MSHTML and SHDocVw and already write ComRegister function, unregister function

  [ComRegisterFunction]
    public static void RegisterBHO(Type type)
    {
        RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);

        if (registryKey == null)
        {
            registryKey = Registry.LocalMachine.CreateSubKey(BHOKEYNAME);
        }
        string guid = type.GUID.ToString("B");
        RegistryKey ourKey = registryKey.OpenSubKey(guid);
        if (ourKey == null)
        {
            ourKey = registryKey.CreateSubKey(guid);
        }
        ourKey.SetValue("Alright", 1);
        registryKey.Close();
        ourKey.Close();
    }
 [ComUnregisterFunction]
    public static void UnregisterBHO(Type type)
    {
        RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME, true);
        string guid = type.GUID.ToString("B");

        if (registryKey != null)
        {
            registryKey.DeleteSubKey(guid, false);
        }
    }
and already write set / getsite functions

public int SetSite([MarshalAs(UnmanagedType.IUnknown)] object site)
        {
        if (site != null)
        {
            webBrowser = (SHDocVw.WebBrowser)site;
            webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
            webBrowser.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
            webBrowser.NavigateComplete2 += WebBrowser_NavigateComplete2;
        }
        else
        {
            webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
            webBrowser.BeforeNavigate2 -= new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
            webBrowser.NavigateComplete2 -= WebBrowser_NavigateComplete2;
            webBrowser = null;
        }
        return 0;
    }
    private void WebBrowser_NavigateComplete2(object pDisp, ref object URL)
    {

    }
    public int GetSite(ref Guid guid, out IntPtr ppvSite)
        {
        IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
        int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
        Marshal.Release(punk);
        return hr;
    }


then i add a setup project

so when i setup the project cant see my "add-on " in internet explorer

can you help pls ?

What I have tried:

i have tried to download and setup this project

http://www.codeproject.com/Articles/19971/How-to-attach-to-Browser-Helper-Object-BHO-with-C

so its not working for me
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900