VarBstrFromI4 更改程序中其他一些 BSTR 的值
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);
最后一行 VarBstrFromI4 将索引(BSTR)的值更改为我想要的值,同时还将长度(BSTR)的值更改为索引(BSTR)的值。我一直在尝试执行许多选项,包括带有索引和长度的 SysAllocString,但同样的问题仍然存在。
请帮忙。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦你在一个字符串上调用了 SysFreeString ,你就不应该再关心这个字符串了。释放的字符串在内部保存已释放内存的地址,该内存稍后可能由另一个字符串或变量分配。在这种情况下,新字符串恰好被放置在与旧字符串相同的内存地址处。
Once you have called
SysFreeString
on a string you should not care about that string anymore. The freed string holds an address internally to deallocated memory which may later be allocated by another string or variable. In this case it just happens that the new string is placed at the same memory address as the old string.