Passing JScript string array to Activex  
Author Message
smk_k





PostPosted: Internet Explorer Extension Development, Passing JScript string array to Activex Top

I want to pass an JScript string array to java script. Can anyone explain me how to do it.

Thanks




Internet Explorer Development6  
 
 
kevin7776





PostPosted: Internet Explorer Extension Development, Passing JScript string array to Activex Top

VARIANT varParams; //this is a JScript array passed in

//if not VT_DISPATCH then return.
if(varParams.vt!=VT_DISPATCH)
return E_INVALIDARG;

//get the IDispatchEx of varParams
CComPtr<IDispatchEx> pDispEx;
HRESULT hr=varParams.pdispVal->QueryInterface(IID_IDispatchEx,(void**)&pDispEx);
if(FAILED(hr))
return E_INVALIDARG;

//Enum all the properties of the jscript array.
DISPID dispid;

//get the DISPID of the first item.
hr = pDispEx->GetNextDispID(fdexEnumAll, DISPID_STARTENUM, &dispid);
while (hr == NOERROR)
{
//get the item name
CComBSTR bstrName;
hr = pDispEx->GetMemberName(dispid, &bstrName);
if (FAILED(hr))
return E_FAIL;

//get the item value
CComVariant vValue;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
hr = pDispEx->InvokeEx(dispid, LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET, &dispparamsNoArgs,
&vValue, NULL, NULL);
if(FAILED(hr))
return E_FAIL;

//get the DISPID of the next item.
hr = pDispEx->GetNextDispID(fdexEnumAll, dispid, &dispid);
}