BSTR length;
BSTR checkLength = SysAllocString(TEXT("document.getElementsByTagName('tspan').length.toString()"));
HRESULT h = gWebView->stringByEvaluatingJavaScriptFromString(checkLength, &length);
SysFreeString(checkLength);
long longLength;
h = VarI4FromStr(length,0,0,&longLength);
SysFreeString(length);
BSTR index;
long longIndex = longLength - 1;
h = VarBstrFromI4(longIndex,0,0,&index);
The last line VarBstrFromI4 changes the value of index(BSTR) to my desired value but also changes the value of length(BSTR) to the value of index(BSTR). I have been trying to do many options including SysAllocString with index and length but the same problem persists.
Please help.