在 IWebBrowser2 OLE 控件中禁用脚本调试? C++
我有一个 IWebBrowser2,用于通过 .Navigate() 访问一些网页 当页面出现 js 错误时,我收到“语法错误”的警告框,因此我使用 .put_Silent(TRUE)。现在,我收到了“VS Just-In-Time Debugger:未处理的异常”警告
如何从我的代码中禁用所有脚本错误警告(包括 JIT 调试器) (我的意思是不修改真实的 IE 设置)?
I have a IWebBrowser2 I use to visit some webpages with .Navigate()
When the page has a js error I got a warning box for "Syntax error", so I used .put_Silent(TRUE). And now I get a warning for "VS Just-In-Time Debugger: Unhandled exception" instead
How can I disable all the script error warnings (including JIT debugger) from my code (i mean without modifying the real IE settings)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过覆盖控制脚本调试的注册表设置来禁用脚本调试。正确的方法是实现 IDocHostUIHandler 接口,特别是 IDocHostUIHandler: :GetOptionKeyPath 或 IDocHostUIHandler::GetOverrideKeyPath方法。使用 GetOptionKeyPath 忽略所有用户的 IE 设置(例如,字体大小)并使用 IE 默认值,或使用 GetOverrideKeyPath 使用大多数用户的 IE 设置但覆盖一些特定的设置。
上面链接的 MSDN 文章包含有关如何使用此接口的良好文档,以及 IDocHostUIHandler 接口及其方法的示例实现。
假设您的 GetOptionKeyPath 方法返回“SOFTWARE\MyCompany\MyApp\IE” 作为新的注册表路径。要确保禁用脚本调试,您需要创建
HKEY_CURRENT_USER\Software\MyCompany\MyApp\IE\Main
注册表项,然后创建一个名为Disable Script Debugger
的字符串值> 值为yes
。You can disable script debugging by overriding the registry settings that control it. The correct way to do this is to implement the IDocHostUIHandler interface, and specifically the IDocHostUIHandler::GetOptionKeyPath or IDocHostUIHandler::GetOverrideKeyPath methods. Use GetOptionKeyPath to ignore all the user's IE settings (e.g., font size) and use IE defaults, or GetOverrideKeyPath to use most of the user's IE settings but override a few specific ones.
The MSDN articles linked above contain good documentation on how to use this interface, as well as sample implementations of the IDocHostUIHandler interface and its methods.
Say that your GetOptionKeyPath method returns
"SOFTWARE\MyCompany\MyApp\IE"
as the new registry path. To ensure that script debugging is disabled, you would need to create theHKEY_CURRENT_USER\Software\MyCompany\MyApp\IE\Main
registry key, then create a string value namedDisable Script Debugger
having the valueyes
.