读书人

获取frames的有关问题

发布时间: 2012-02-08 19:52:21 作者: rapoo

获取frames的问题
IHTMLDocument2 *pHTMLDoc=NULL;
IHTMLFramesCollection2 *pFrames;
LPDISPATCH pDisp;
VARIANT id,index;
pDisp=mycwb-> Document;
if(pDisp)
{
}
else
{
ShowMessage( "Document read error. ");
return;

}
if(SUCCEEDED(pDisp-> QueryInterface(IID_IHTMLDocument2,(void **)&pHTMLDoc)))
{
}
else
{return;}
//pDisp-> Release();
IHTMLElementCollection *pelement;
if(pHTMLDoc-> get_forms(&pelement)!=S_OK) //得到form指针
{
pHTMLDoc-> Release();
pDisp-> Release();
pelement-> Release();
ShowMessage( "read form failed! ");
return;
}
long p;
pelement-> get_length(&p); //form的个数
ShowMessage( " Forms: "+IntToStr(p));
if(p> 0)
{
for (long i=0;i <p;i++)
{
V_VT(&id)=VT_I4;
V_I4(&id)=i;
V_VT(&index)=VT_I4;
V_I4(&index)=0;
}
}
//如果forms是0,那么取fremes数
if(p <=0)
{
if(pHTMLDoc-> get_frames(&pFrames)!=S_OK); //得到frames指针
{
pHTMLDoc-> Release();
pDisp-> Release();
pFrames-> Release();
ShowMessage( "read frames failed! ");
return;
}
......
}
我做的一个测试程序,提取表单没有问题,为什么老是提示read frames failed!,请高手帮忙看看

[解决办法]
看代码觉得没问题。

读书人网 >C++ Builder

热点推荐