发布网友
共1个回答
热心网友
void CHtmlradioselView::submit()
LPDISPATCH lpdisp=this->GetHtmlDocument();
IHTMLDocument2* spHtmlDocument=NULL;
HRESULT hr=lpdisp->QueryInterface(IID_IHTMLDocument2,(void**)&spHtmlDocument);
IHTMLElementCollection* pColl=NULL;
hr=spHtmlDocument->get_all(&pColl);
if(pColl!=NULL&&SUCCEEDED(hr))
LPDISPATCH pdisp=NULL;
IHTMLInputElement* pelem=NULL;
long num=0;
pColl->get_length(&num);
for(int i=0;i<num;i++)
hr=pColl->item(COleVariant((short)i),COleVariant((short)i),&pdisp);
if(SUCCEEDED(hr)&&pdisp!=NULL)
hr=pdisp->QueryInterface(IID_IHTMLInputElement,(void**)&pelem);
if(SUCCEEDED(hr)&&pelem!=NULL)
bool bfind=false;
BSTR bstrtype;
pelem->get_type(&bstrtype);
if(wcsicmp(bstrtype,L"submit")==0)
IHTMLElement* petmp =NULL;
pelem->QueryInterface(IID_IHTMLElement,(void**)&petmp);
petmp->click();
petmp->Release();
bfind=true;
SysFreeString(bstrtype);
pelem->Release();
if(bfind)
break;
pdisp->Release();
pColl->Release();
if(spHtmlDocument!=NULL)
spHtmlDocument->Release();
if(lpdisp!=NULL)
lpdisp->Release();