使用DISPID_NEWENUM在C ++中检索JavaScript数组对象在IE9上失败 [英] Retrieve javascript array object with C++ using DISPID_NEWENUM fails on IE9

查看:198
本文介绍了使用DISPID_NEWENUM在C ++中检索JavaScript数组对象在IE9上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之后我回答了一个类似问题,我发现当尝试枚举对象时,使用 IDispatch :: Invoke(DISPID_NEWENUM,...)失败, DISP_E_EXCEPTION 在IE9上。

这发生在任何javascript数组上的 IDispatch IDispatchEx

following a similar question i answered some time ago, i found out that when trying to enumerate the object, using IDispatch::Invoke(DISPID_NEWENUM,...) fails with DISP_E_EXCEPTION on IE9.
This happens with IDispatch and IDispatchEx, on any javascript array.

不必说,该代码在IE6-IE8上运行良好,只在IE9上失败。

needless to say that the code works great on IE6-IE8, and fails only on IE9.

同一问题也会显示在 MSDN中开发论坛,没有运气到目前为止。

The same question also appears in the MSDN dev forums with no luck so far.

这里有一段代码片段来演示我试图做什么。注意 pDispatch 是javascript的数组变量。

Here's a code snippet to demonstrate what I tried to do. notice that pDispatch is the javascript's array variant.

// invoke the object to retrieve the enumerator containing object
CComVariant varResult;

DISPPARAMS dispparamsNoArgs = {0};
EXCEPINFO excepInfo = {0};
UINT uiArgErr = (UINT)-1;  // initialize to invalid arg
HRESULT hr = pDispatch->Invoke(DISPID_NEWENUM, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD | DISPATCH_PROPERTYGET, &dispparamsNoArgs, &varResult, &excepInfo, &uiArgErr);

// if failed - retry with IDispatchEX
if (FAILED(hr))
{
   CComPtr<IDispatchEx> pDispatchEx;
   pDispatchEx = pDispatch; // Implied query interface

   hr = pDispatchEx->InvokeEx(DISPID_NEWENUM, LOCALE_USER_DEFAULT, DISPATCH_METHOD | DISPATCH_PROPERTYGET, &dispparamsNoArgs, &varResult, &excepInfo, NULL);

   if (FAILED(hr))
      return false;
}

有没有人知道为什么这个代码总是失败(IDispatch和IDispatchEx) HRESULT of DISP_E_EXCEPTION in specific IE9?

Does anyone have any idea why this code always fails (IDispatch and IDispatchEx) with HRESULT of DISP_E_EXCEPTION specifically on IE9?

感谢。

推荐答案

IEnumVARIANT可能工作。
虽然当我尝试它IEnumVARIANT :: Next总是返回E_FAIL,
元素正确取得。没有时间或需要到达底部。

IEnumVARIANT may work. Although when I tried it IEnumVARIANT::Next always was returning E_FAIL, the element was fetched correctly. Didn't have time or need to get to the bottom of this.

它为我工作,但如果它不是我打算使用IDispatchEx:
当枚举成员的数组对象通过IE,他们都有 0,1等..,而不是长度方法虽然,必须在它的typeinfo,还没有检查。
我想你的想法。

It worked for me, but if it didn't I was intended to use IDispatchEx: when enumerated members of array objects passed by IE they all had "0", "1" etc.., not "length" method though, must be in it's typeinfo, haven't checked. I think you get the idea.

对不起,不能发布伪代码这个网站将不允许我没有遵循一些特殊的格式规则

Sorry can't post pseudo code this site won't allow me without following some special formatting rules

这篇关于使用DISPID_NEWENUM在C ++中检索JavaScript数组对象在IE9上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆