处理 .NET WebBrowser 控件中的安全消息
我正在尝试编写一个 VB.net 应用程序,该应用程序将允许用户在 html/jscript 中创建自己的小部件插件,并且我想在应用程序设置中设置自己的安全选项,允许用户选择可以运行或不运行的内容,例如脚本,闪存、Activex。
我想允许在没有 WebBrowser 控件中的 Windows 安全对话框的情况下使用 ActiveX 控件(ActiveX 控件正在尝试与页面交互...)或它所说的任何内容。
我开始自定义 WB 控件以满足我的需要,实现各种接口,例如 IOleClientSite、IDocHostShowUI、IDocHostUIHandler 等...
我似乎找不到任何可以让我控制 WB 控件的安全权限的东西。我尝试实现 IHttpSecurity 和 IInternetSecurityManager 但我要么找错了树,要么做得不对。
I am attempting to write a VB.net application which will allow users to create their own widget plugins in html/jscript and i would like to set my own security options in the applications settings allowing users to choose what can run or not eg scripts, flash, activex.
I would like to allow activex controls to be used without the windows security dialog in the WebBrowser Control (An ActiveX control is trying to interact with the page...) or what ever it says.
I started customizing the WB Control to suite my needs implementing various interfaces such as IOleClientSite, IDocHostShowUI, IDocHostUIHandler, etc...
I can't seem to find anything that will allow me to control the security permissions of the WB Control. I tried to implement IHttpSecurity and IInternetSecurityManager but I'm either barking up the wrong tree or not doing it right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用此代码:
在 WebBrowser 中处理
Use this code:
Handle in WebBrowser
WebBrowser 控件只是 Internet Explorer 的另一个实例,因此继承了 IE 中的安全设置。
除了在 IE 本身中编辑它们之外,我没有找到其他更改安全选项的方法。您很可能也可以更改注册表中的设置,但它们对于所有 IE 实例都是全局的。如果您在代码中更改它,那么您也可以为所有浏览器实例更改它。
在我不久前编写的一个自动化应用程序中,我通过监视窗口弹出窗口、抓住窗口句柄并向该窗口中的按钮发送单击来处理弹出窗口。当然不是一个优雅的解决方案:(
The WebBrowser control is just another instance of Internet Explorer, and thus inherits the security settings in IE.
I have found no other way of changing the security options than to edit them in IE itself. You can most likely change the settings in registry as well, but they will be global for all IE instances. If you change it in your code, then you change it for all browser instances as well.
In an automated application I wrote some time ago I disposed of the pop-ups by monitoring for window pop-ups, grabbing the window handle and sending a click to the button in that window. Certainly not an elegant solution :(
IInternetSecurityManager 需要 IQueryInterface。
我的应用程序中没有实现 IQueryInterface,这就是它无法工作的原因。
IInternetSecurityManager requires IQueryInterface.
I didn't have IQueryInterface implemented in my application which was why it wasn't working.
IHttpSecurity 和 IInternetSecurityManager 应该可以工作,您的实现是什么样的?检查 https://learn .microsoft.com/en-us/previous-versions/windows/desktop/cc507439%28v%3dvs.85%29 为例。
IHttpSecurity and IInternetSecurityManager should work, how is your implementation look like? Check https://learn.microsoft.com/en-us/previous-versions/windows/desktop/cc507439%28v%3dvs.85%29 for an example.