有框架的网页,如何读取框架里的源码

2020-10-11 社会 46阅读
用chtmlview打带框架网页写面函数
BOOL CHtmlView::GetFrameSource( IDispatch *pDisp, CString& refString )
{
BOOL bRetVal = FALSE;
HRESULT hr = S_OK;
if ( pDisp != NULL )
{
CComQIPtr pBrowser = pDisp;
if ( pBrowser != NULL )
{
IDispatch *pDispDoc = NULL;
hr = pBrowser->get_Document(&pDispDoc);
if ( !( FAILED(hr) || !pDisp ) )
{
CComQIPtr pStmInit = pDisp;
if ( !pStmInit )
{
HGLOBAL hMemory;
hMemory = GlobalAlloc(GMEM_MOVEABLE, 0);
if (hMemory != NULL)
{
CComQIPtr spPSI = pDispDoc;
if( spPSI != NULL)
{
CComPtr spStream;
if (SUCCEEDED(CreateStreamOnHGlobal(hMemory, TRUE, &spStream)))
{
spPSI->Save(spStream, FALSE);
LPCTSTR pstr = (LPCTSTR) GlobalLock(hMemory);
if (pstr != NULL)
{
// Stream is always ANSI, but CString
// assignment operator will convert implicitly.
bRetVal = TRUE;
TRY
{
refString = pstr;
}
CATCH_ALL(e)
{
bRetVal = FALSE;
DELETE_EXCEPTION(e);
}
END_CATCH_ALL

if(bRetVal == FALSE)
GlobalFree(hMemory);
else
GlobalUnlock(hMemory);
}
}
}
}
}
}
RELEASE(pDispDoc);
}
}
return bRetVal;
}

能用DocumentComplete我知道获pDisp像DocumentComplete才能获框架各页pDisp没通用性我想要实现像GetSource功能要网页载完毕任意刻获框架html源文件!
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com