Internet Explorer BHO检查站点的多实例 [英] Internet Explorer BHO check for multi-instance of site

查看:215
本文介绍了Internet Explorer BHO检查站点的多实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为客户开发一个项目。我们正在建立一个内部门户网站,并且由于各种(主要是政治)原因,最终建立了IE8的BHO。其中一件事是make sur,只有一个实例的门户可以一次打开。它通过在打开门户时编写一个临时文件来实现。不幸的是,这不是最佳的,因为如果IE崩溃任何原因,然后下一次门户网站启动,用户留下盯着未经授权的消息,直到陈旧的临时文件被删除。
所以我的问题是:在BHO中有没有办法看到同一个网址已经加载了多少次?我的意思是有一些方法来直接从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.

感谢您的时间。

推荐答案

如果您希望在当前用户会话中限制浏览器实例,可以使用互斥体而不是文件。尝试在BHO启动时(在SetSite调用中)以合理的超时获取互斥体,并在最终的SetSite调用中再次释放。

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.

如果结果为WAIT_OBJECT_0或WAIT_ABANDONED,没有其他BHO实例持有互斥体,而WAIT_ABANDONED发生时,另一个线程在持有互斥体时崩溃。如果结果是WAIT_TIMEOUT,互斥体已由另一个BHO实例占用,您不应该让用户根据您的要求使用您的网站。

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.

但如果我是一个确定的用户,我可以启动XP模式并访问该网站...

But if I am a determined user I can fire up XP Mode and access the web site from there...

这篇关于Internet Explorer BHO检查站点的多实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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