Internet Explorer BHO 检查站点的多实例
我正在为客户做一个项目。我们正在构建一个内部门户网站,由于各种(主要是政治)原因,我们最终为 IE8 构建了一个 BHO。 t 所做的事情之一是确保一次只能打开一个门户实例。它通过在门户打开时写入临时文件来实现此目的。不幸的是,这并不是最佳选择,因为如果 IE 由于任何原因崩溃,那么下次启动门户时,用户就会盯着“未经授权”的消息,直到删除过时的临时文件。 所以我的问题是:BHO 中是否有任何方法可以查看同一个 url 已加载了多少次?我的意思是有什么方法可以直接从 IE 获取该信息吗? 它实际上比这更复杂一点,因为我们需要允许弹出窗口等。但这将是一个好的开始。
感谢您抽出时间。
I'm working on a project for a client. We are building an internal web portal, and for various (mostly political) reasons have ended up building a BHO for IE8. One of the things t does is make sur that only one instance of the portal can be opened at once. It does this by writing a temp file when the portal is opened. Unfortunately this is not optimal as if IE crashes for any reason then the next time the portal is fired up, the user is left staring at an "unauthorised" message until the stale temp file is removed.
So my question is: is there any way within a BHO to see how many times the same url has been loaded? I mean is there some way to get that information directly from IE?
It's actually a little more complicated than that, given that we need to allow popups etc. But this would be a good start.
Thanks for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想限制当前用户会话中的浏览器实例,您可以使用互斥体而不是文件。尝试在 BHO 启动时(在 SetSite 调用中)以合理的超时获取互斥体,并在最终的 SetSite 调用中再次释放。
如果结果是 WAIT_OBJECT_0 或 WAIT_ABANDONED,则表示没有其他 BHO 实例持有互斥锁,而当另一个线程在持有互斥锁时崩溃时,就会发生 WAIT_ABANDONED。如果结果是 WAIT_TIMEOUT,则互斥体已被另一个 BHO 实例占用,您不应该让用户根据您的要求使用您的网站。
但如果我是一个坚定的用户,我可以启动 XP 模式并从那里访问网站......
If you want limit browser instances in the current user session you can use a mutex instead of a file. try acquire the mutex at the startup of the BHO (in the SetSite call) with a reasonable timeout, and release again in the final SetSite call.
If the result is WAIT_OBJECT_0 or WAIT_ABANDONED, there is no other BHO instance holding the mutex, while WAIT_ABANDONED occur when another thread crashed while holding the mutex. If the result is WAIT_TIMEOUT, the mutex is already taken by another BHO instance and you should not let the user to use your web site according to your requirement.
But if I am a determined user I can fire up XP Mode and access the web site from there...