想要在嵌入标准 C# 应用程序的 WebBrowser 控件中启用 BHO [英] Want to enable BHO in a WebBrowser Control embedded in a standard C# App

查看:22
本文介绍了想要在嵌入标准 C# 应用程序的 WebBrowser 控件中启用 BHO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标准的 winforms C# 应用程序,上面拖着一个 webbrowser 控件.我们还有一个 C++ BHO,当它在 IE7 或 IE8 中运行时,我们通常通过 COM 与之交互.

I have a standard winforms C# app with a webbrowser control dragged onto it. We also have a C++ BHO that we generally interact with through COM when it runs inside IE7 or IE8.

我没有看到任何方法可以告诉 webbrowser 控件加载 BHO.BHO 不显示任何 GUI 或任何东西,它只是在从 IE 使用时侦听 http 流量.

I don't see any way to tell the webbrowser control to load the BHO. The BHO doesn't show any GUI or anything, it just listens to the http traffic when used from IE.

任何帮助将不胜感激.谢谢.

Any help would be greatly appreciated. Thanks.

推荐答案

BHO 只是实现 IObjectWithSite 的 COM 对象.您可以只创建 BHO 的一个实例,查询 IObjectWithSite 并调用 IObjectWithSite::SetSite,将 webbrowser 控件的 IWebBrowser2 指针作为参数传递.关闭时,再次调用 SetSite,传递 NULL.

BHOs are just COM objects who implement IObjectWithSite. You can just create a instance of your BHO, query for IObjectWithSite and call IObjectWithSite::SetSite, passing IWebBrowser2 pointer of the webbrowser control as a parameter. When you are shutting down, call SetSite again, passing NULL.

如果您托管其他人编写的 BHO,您也需要满足他们的要求,有些可能要求您的程序命名为iexplore.exe",有些可能要求您具有与特定版本的 IE 相同的窗口层次结构等

If you are hosting BHOs written by others you need to satisfy their requirement as well, some may require your program to be named "iexplore.exe", some may require you to have the same window hierarchy as a particular version of IE, etc.

这篇关于想要在嵌入标准 C# 应用程序的 WebBrowser 控件中启用 BHO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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