如何在C#中运行多个BHO(浏览器助手对象)? [英] How to run Multiple BHO (Browser Helper Objects) in C#?

查看:36
本文介绍了如何在C#中运行多个BHO(浏览器助手对象)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人帮忙,



是否可以同时运行多个BHO?

在这种情况下,



i必须生成2个BHO(2个附加组件),名称不同,



但是当我打开IE时,

第一个BHO运行良好,但

第二个BHO没有运行,



有一个解决方案这个案子?



感谢'的

解决方案

公共课BHO: IObjectWithSite 
{
WebBrowser webBrowser;
HTMLDocument文档;
public void OnDocumentComplete(object pDisp,ref object URL)
{
document =(HTMLDocument)webBrowser.Document;
string href = document.location.href;
//获取顶级页面
if(href == URL.ToString())
{
HttpWebRequest WebReq =(HttpWebRequest)WebRequest.Create(http:// mysite .COM);
WebReq.Method =POST;
WebReq.ContentType =application / x-www-form-urlencoded;
byte [] buffer = Encoding.ASCII.GetBytes(string);
WebReq.ContentLength = buffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(buffer,0,buffer.Length);
PostData.Close();
//准备Web请求并发送数据。
HttpWebResponse WebResp =(HttpWebResponse)WebReq.GetResponse();
StreamReader streamResponse = new StreamReader(WebResp.GetResponseStream(),true);
string Response = streamResponse.ReadToEnd();
Newtonsoft.Json.Linq.JObject json = Newtonsoft.Json.Linq.JObject.Parse(Response);
string active = json [active]。ToString();
//打印到屏幕
System.Windows.Forms.MessageBox.Show(active,Title);
}
}







http://stackoverflow.com/questions/8588808/next-steps-debugging-crash-in-customer-environment [ ^


please somebody help,,

is it possible to run multiple BHO in same time?
in this case,

i have to generate 2 BHO (2 add-ons) with different name,

but when i opened IE ,
the 1st BHO running well,but
the 2nd BHO is not running,

have somebody solution for this case?

Thank''s

解决方案

public class BHO:IObjectWithSite
{
    WebBrowser webBrowser;
    HTMLDocument document;
    public void OnDocumentComplete(object pDisp, ref object URL)
    {
        document = (HTMLDocument)webBrowser.Document;
        string href = document.location.href;
        //get top level page
        if (href == URL.ToString())
        {
            HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://mysite.com");
            WebReq.Method = "POST";
            WebReq.ContentType = "application/x-www-form-urlencoded";
            byte[] buffer = Encoding.ASCII.GetBytes("string");
            WebReq.ContentLength = buffer.Length;
            Stream PostData = WebReq.GetRequestStream();
            PostData.Write(buffer, 0, buffer.Length);
            PostData.Close();
            // Prepare web request and send the data.
            HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
            StreamReader streamResponse = new StreamReader(WebResp.GetResponseStream(), true);
            string Response = streamResponse.ReadToEnd();
            Newtonsoft.Json.Linq.JObject json = Newtonsoft.Json.Linq.JObject.Parse(Response);
            string active = json["active"].ToString();
            //print to screen
            System.Windows.Forms.MessageBox.Show(active, "Title");
        }
    }




http://stackoverflow.com/questions/8588808/next-steps-debugging-crash-in-customer-environment[^]


这篇关于如何在C#中运行多个BHO(浏览器助手对象)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆