IID_IPersistStreamInit 的 QueryInterface 方法停止工作
我有一个应用程序,一直用来解析 HTML 文档中的数据。该应用程序已经工作了几年,直到本周 IID_IPersistStreamInit 的 QueryInterface 方法开始失败。对 QueryInterface 的调用返回 -2147467262,它未通过 SUCCEEDED(hr) 测试。有什么想法为什么会停止工作吗?
谢谢, 韦德
if (!myIE->IsValid())
return;
HRESULT hr;
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
LPPERSISTSTREAM lpPersistStream = NULL;
lpDispatch = myIE->GetHtmlDocument();
ASSERT(lpDispatch);
if (lpDispatch == NULL)
AfxMessageBox("Couldn't get IHTMLDocument2 interface!");
else
{
hr = lpDispatch->QueryInterface(IID_IPersistStreamInit, (void**) &lpPersistStream);
if (SUCCEEDED(hr) && lpPersistStream != NULL)
I have an application that I've been using to parse data from an HTML document. The application has been working for a few years until this week when the QueryInterface method for the IID_IPersistStreamInit started failing. The call to QueryInterface is returning -2147467262 which fails the SUCCEEDED(hr) test. Any ideas why this quit working?
Thanks,
Wade
if (!myIE->IsValid())
return;
HRESULT hr;
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
LPPERSISTSTREAM lpPersistStream = NULL;
lpDispatch = myIE->GetHtmlDocument();
ASSERT(lpDispatch);
if (lpDispatch == NULL)
AfxMessageBox("Couldn't get IHTMLDocument2 interface!");
else
{
hr = lpDispatch->QueryInterface(IID_IPersistStreamInit, (void**) &lpPersistStream);
if (SUCCEEDED(hr) && lpPersistStream != NULL)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在什么时候执行上面的代码?如果未完成,您应该仅在执行以下操作后执行它:
只有这样才能安全地请求流接口。有关详细信息,请参阅从流加载 HTML 内容。
现在,如果所有这些都已了解并得到解决,您可能会从另一个方向寻求解决方案。错误代码的意思是“不支持此类接口”。我会尝试找出包含该接口的组件是什么,然后重新注册它。但考虑到这是你正在处理的 IE 东西,我有点怀疑它的安装被搞砸了。
At what point are you executing the code above? In case it's not done, you should execute it only after the followings:
Only then is it safe to ask for the stream interface. For more, see Loading HTML content from a Stream.
Now, if all this is known and taken care of, you might pursue the solution from the other direction. The error code means "No such interface supported". I'd try finding out what is the component that contains that interface, and then re-register it. But given this is IE stuff you're dealing with, I kind of doubt it's installation got screwed.