IWebBrowser2

20 views
Skip to first unread message

AF

unread,
May 14, 2010, 4:37:45 AM5/14/10
to
I have an instance of IWebBrowser2 and make calls into the JScript of its
loaded HTML page from my C++ app. The IWebBrowser2 interface was created in
the main UI thread, if I make calls into the JScript in the main UI thread
everything is fine but if I try and make calls into the JScript in a worker
thread I get an E_ACCESSDENIED error message from the scripting engines
IDispatch::Invoke. In both cases the method used to call into the JScript is
the same i.e. get an IHTMLDocument2 interface from
IWebBrowser2::get_Document, then get the scripting engine IDispatch
interface from IHTMLDocument2::get_Script, then call Invoke on that
IDispatch interface. I develop using VS 2008 under Window 7. Any help would
be great.

A.

Igor Tandetnik

unread,
May 14, 2010, 8:02:48 AM5/14/10
to
AF wrote:
> I have an instance of IWebBrowser2 and make calls into the JScript of its
> loaded HTML page from my C++ app. The IWebBrowser2 interface was created in
> the main UI thread, if I make calls into the JScript in the main UI thread
> everything is fine but if I try and make calls into the JScript in a worker
> thread I get an E_ACCESSDENIED error message from the scripting engines
> IDispatch::Invoke.

So, don't do that. JavaScript engine is single-threaded. At the very least, you should properly marshal interface pointers from main to worker thread (but then you lose most of the benefits of the worker thread to begin with).
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925

Reply all
Reply to author
Forward
0 new messages