IE plugin bho

Source: Internet
Author: User

BHO Project (class library) add a reference to two Com//microsoft HTML Object Library, Microsoft Internet controls;using System.Runtime.InteropServices ; namespace testbho{    [ComVisible (True), InterfaceType (Cominterfacetype.interfaceisiunknown), Guid (" fc4801a3-2ba9-11cf-a229-00aa003d7352 ")] public    interface IObjectWithSite    {        [preservesig]        int SetSite ([MarshalAs (Unmanagedtype.iunknown)]object site);        [PreserveSig]        int Getsite (ref GUID GUID, out IntPtr ppvsite);}    }

Using microsoft.win32;using mshtml;using shdocvw;namespace testbh{//each open IE Browser option page will create an instance of the Mybho class to correspond to the IE Options page//ie8 is each TA b A standalone process that, when the tab process of IE is created, creates an instance of the Mybho class [ComVisible (True), a Guid ("8A194578-81EA-4850-9911-13BA2D71EFBD"),        ClassInterface (ClassInterfaceType.None)] public class Mybho:iobjectwithsite {InternetExplorer ie;        Frmbho frm;        Logs Logs = new Logs (); public int SetSite (object site) {if (site! = null) {ie = (InternetExplorer) s                Ite Logs.                ADD ("bho Build"); Ie.            DocumentComplete + = new Dwebbrowserevents2_documentcompleteeventhandler (ie_documentcomplete); } else {ie.            DocumentComplete-= new Dwebbrowserevents2_documentcompleteeventhandler (ie_documentcomplete);        } return 0; } private void Ie_documentcomplete (object pdisp, ref object URL) {if (URL. ToString (). StartsWith ("Http://116.252.254.204:8001/")) {logs. ADD (URL.                ToString ()); Logs.                ADD ("-----------------------------------------"); Logs. Add (ie.                Locationurl); Logs. Add (ie.                LocationName); Logs. Add (ie.                Name); Logs.                ADD ("-----------------------------------------");                if (frm==null) frm = new frmbho (logs); frm.                Show (); frm.            Showtext (); }} public int getsite (ref GUID GUID, out IntPtr ppvsite) {IntPtr punk = Marshal.getiunkn            Ownforobject (IE);            int hr = Marshal.queryinterface (punk, ref GUID, out ppvsite);            Marshal.release (Punk);        return HR; } #region register bho public static string key = "Software\\microsoft\\windows\\currentversion\\explorer\\browser        Helper Objects "; [comregisterfunction] public static void Registerbho (type type) {RegistryKey RegistryKey = RegisTry.            Localmachine.opensubkey (key, true);            if (RegistryKey = = null) RegistryKey = Registry.LocalMachine.CreateSubKey (key); String guid = type. Guid.            ToString ("B");            RegistryKey Ourkey = Registrykey.opensubkey (GUID);            if (Ourkey = = null) Ourkey = Registrykey.createsubkey (GUID);            Registrykey.close ();        Ourkey.close (); } [comunregisterfunction] public static void Unregisterbho (type type) {RegistryKey regist            Rykey = Registry.LocalMachine.OpenSubKey (key, true); String guid = type. Guid.            ToString ("B");        if (RegistryKey! = null) Registrykey.deletesubkey (GUID, false);  } #endregion}

IE plugin bho

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.