IPersistStreamInit::Save() 在 IE9 中不起作用?
此代码适用于 IE8 及更早版本。对于 IE9,IPersistStreamInit::Save() 似乎返回 E_NOTIMPL。非常感谢任何帮助!
HRESULT CHtmlCtrl::GetDocumentHTML(CString& strHTML) const
{
HRESULT hr = E_NOINTERFACE;
CComPtr<IHTMLDocument2> spHTMLDocument;
GetHtmlDocument()->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&spHTMLDocument);
if (spHTMLDocument)
{
CComQIPtr<IPersistStreamInit> spPSI;
spPSI = spHTMLDocument;
if (spPSI)
{
CStreamOnCString stream;
hr = spPSI->Save(static_cast<IStream*>(&stream), FALSE);
if (hr == S_OK)
{
if (!stream.CopyData(strHTML))
hr = E_OUTOFMEMORY;
}
}
}
return hr;
}
This code worked for IE8 and earlier. For IE9 it seems that IPersistStreamInit::Save() returns E_NOTIMPL. Any help is greatly appreciated!
HRESULT CHtmlCtrl::GetDocumentHTML(CString& strHTML) const
{
HRESULT hr = E_NOINTERFACE;
CComPtr<IHTMLDocument2> spHTMLDocument;
GetHtmlDocument()->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&spHTMLDocument);
if (spHTMLDocument)
{
CComQIPtr<IPersistStreamInit> spPSI;
spPSI = spHTMLDocument;
if (spPSI)
{
CStreamOnCString stream;
hr = spPSI->Save(static_cast<IStream*>(&stream), FALSE);
if (hr == S_OK)
{
if (!stream.CopyData(strHTML))
hr = E_OUTOFMEMORY;
}
}
}
return hr;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如所描述和确认的,似乎是 MFC 中的错误 这里。 已在 Visual Studio 2012 RTM 中修复。
Seems to be a bug in the MFC as described and confirmed here. Fixed in Visual Studio 2012 RTM.