Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4092886
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:32:54+00:00 2026-05-20T19:32:54+00:00

I have an Internet Explorer BHO that can execute a script on the current

  • 0

I have an Internet Explorer BHO that can execute a script on the current website and then read variables that have been assigned in that script. Unfortunately, as of IE9 (I tested with the RC), reading the JS variable results in a HRESULT 0x80020006.

The script sets assigns the JS variable as follows:

this.<js_var> = <value>

where this is the current Window object. It is executed using

hr = pWindow->execScript( ccom_js, lang, &vEmpty );

and the JS variable is read using

bool get_js_var( CComPtr<IDispatch> pDisp, LPOLESTR name, VARIANT *dest )
{
  DISPID id;
  HRESULT hr = pDisp->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, &id );
  if ( SUCCEEDED( hr ) ) {
    VariantInit( dest );
    VariantClear( dest );
    DISPPARAMS dp = { 0, 0, 0, 0 };
    hr = pDisp->Invoke( id, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dp, dest, NULL, NULL );
    if ( SUCCEEDED( hr ) ) {
      return true;
    } else {
      LOG( _T( "failed to get var contents, hresult = 0x%lx" ), hr );
    }
  } else {
    LOG( _T( "failed to get id of var name, hresult = 0x%lx" ), hr );
  }

  return false;
}

where pDisp has been retrieved using document->get_Script( &pDisp );.

This code works fine in previous versions of IE, on Windows XP, Vista and 7. In IE9 the script executes (I can invoke alerts, etc.), but the variable can not be read. What change in IE9 causes this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T19:32:55+00:00Added an answer on May 20, 2026 at 7:32 pm

    While IDispatch->GetIDsOfNames() fails to get a Dispatch ID of the variable in IE9, it turns out that using the result from get_Script() as IDispatchEx instead of IDispatch and calling:

    HRESULT hr = pDispEx->GetDispID( CComBSTR( name ), fdexNameImplicit, &id );
    

    instead of

    RESULT hr = pDisp->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, &id );
    

    does result in a valid and usable id to be used with pDispEx->Invoke().

    To get an IDispatchEx pointer, I used:

    CComPtr<IDispatchEx> pDispEx;
    hr = pDisp->QueryInterface(IID_IDispatchEx, (void**)&pDispEx);`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have developed an internet explorer toolbar or BHO that i would like to
I have a [ComRegisterFunction] that I am using to register a BHO Internet explorer
I have an Internet Explorer only web application. I'm exploring what we can do
I have written a BHO and a toolbar for Internet Explorer in C#. They
Let's say I have internet explorer embedded in a windows form and I then
How can I have a div of static 60px height in Internet Explorer?
I have the following JavaScript code to pop up a window in Internet Explorer.
I have a question to the submit- button behavior of internet explorer. If I
it seems I have run into a problem with Internet Explorer 7. I have
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.