启动 IE 并启用特定 BHO
我有一个 IE BHO 插件,我只想在用户从我的程序启动 IE 时启用该插件(程序使用 CreateProcess()
启动 IE)。
我不希望当用户从我的程序外部启动 IE 时启用此 BHO,因为这意味着 BHO 中的任何问题都可能会扰乱用户的正常浏览体验。
最好的方法是什么?
一种方法是注册 BHO,启动 IE,然后快速取消注册 BHO。但这看起来有点混乱,因为启动 IE 的程序崩溃可能会导致 BHO 保持注册状态。
I have a IE BHO plugin that I only want to be enabled when the user launches IE from my program (The program starts IE using CreateProcess()
).
I don't want this BHO to be enabled when a user launches IE from outside my program, as that would mean any problems in the BHO could potentially mess up the user's normal browsing experience.
What's the best way to do this?
One way would be to register the BHO, launch IE and then quickly unregister the BHO. This seems kind of messy though, as a crash in the program that launches IE could cause the BHO to remain registered.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的方法很容易出错,我建议不要这样做。相反,您的 BHO 应始终加载 IE,但默认情况下它不应该执行任何操作。那么你需要的是一种告诉它“开始过滤”或“开始录制”或其他什么的方法。
那里你有很多选择。最简单的是环境中某处的标志(信号量、磁盘文件)。您可以拥有一个特殊的 url,例如它所监视的
mybho:start
。我已经这样做过很多次了,很有效。
编辑 是的,BHO 将与其依赖的任何 DLL 一起加载到内存中(尽管您可以等待并仅在需要时通过
LoadLibrary()
加载它们)。Your approach is very error-prone, I advise against it. Instead, your BHO should always load with IE, but by default it should do nothing. What you need then is a way to tell it "start filtering" or "start recording" or whatever.
You've got lots of choices from there. The simplest is a flag somewhere in the environment (a semaphore, a disk file). You can have a special url, like
mybho:start
that it watches for.I've done this many times, it works.
Edit Yes, the BHO will be loaded into memory, together with any DLLs it depends on (though you can wait and load them only when needed via
LoadLibrary()
).