Disable script debugging in IWebBrowser2 OLE control? C++

一笑奈何 提交于 2019-11-30 19:54:23

问题


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)?


回答1:


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 the HKEY_CURRENT_USER\Software\MyCompany\MyApp\IE\Main registry key, then create a string value named Disable Script Debugger having the value yes.



来源:https://stackoverflow.com/questions/2936279/disable-script-debugging-in-iwebbrowser2-ole-control-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!