谢谢
解决方案 »
- WTL实现属性对话框
- 有pudn账号的帮忙下个东西
- 请教:::关于连接数据库的m_pRecordset->Open()
- 以服务方式启动的程序如何判断参数?
- Xtreme Toolkit Pro 最新正式版谁知道下载地址?
- BMP(或是jpg)文件的实现问题(高分相赠!)
- 打开了一个程序怎样知道是C编的还是C++编的?
- 如何 判断一个字符串中只含有汉字,数字,和英文,如果真就返回true。如果还有除了以上3中的其他字符就返回false!!
- 怎么创建一个DLL的SETUP程序
- 很土的问题,在CMainFrame中如何调用其他类的函数?请教
- 我不知道搞我这个方向应该选择哪个语言,如何学习,请高手指教!!
- 能不能分割播放一个视频文件?
{
IDispatch* pDisp;
IHTMLDocument2* pHTMLDocument2;
HRESULT hr;
VARIANT id, index;
CString mStr; BSTR bsUserID = m_strUserID.AllocSysString();
BSTR bsPwd = m_strPwd.AllocSysString();
pDisp = GetHtmlDocument();
hr = pDisp->QueryInterface( IID_IHTMLDocument2,
(void**)&pHTMLDocument2 );//Ask for an HTMLDocument2 interface
IHTMLElementCollection* pColl = NULL;//Enumerate the HTML elements
hr = pHTMLDocument2->get_all( &pColl );
if (hr != S_OK || pColl == NULL)
{
pHTMLDocument2->Release();
CoUninitialize();
return;
}
LONG celem;
hr = pColl->get_length( &celem );//Find the count of the elements
if ( hr != S_OK )
{
pHTMLDocument2->Release();
pColl->Release();
CoUninitialize();
return;
}
for ( int i=0; i< celem; i++ )//Loop through each elment
{
IDispatch* pDisp2;
V_VT(&id) = VT_I4;
V_I4(&id) = i;
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
hr = pColl->item( id,index, &pDisp2 );//Get an element
if ( hr == S_OK )
{
IHTMLElement* pElem;
//Ask for an HTMLElemnt interface
hr = pDisp2->QueryInterface(IID_IHTMLElement,(void **)&pElem);
if ( hr == S_OK )
{
BSTR bstr;
IHTMLInputTextElement* pUser;//We need to check for input elemnt on login screen
hr = pDisp2->QueryInterface(IID_IHTMLInputTextElement,(void **)&pUser );
if ( hr == S_OK )
{
pUser->get_name(&bstr);
mStr=bstr;
if(mStr=="email")
{//Is this a User Id frield
pUser->put_value(bsUserID);//Paste the User Id
}
else if(mStr=="passwd")
{//Or, is this a password field
pUser->put_value(bsPwd);// Paste your password into the field
}
pUser->Release();
}
else
{
IHTMLInputImage *pImage = NULL;
pElem->QueryInterface(&pImage);
//hr = pDisp->QueryInterface(IID_IHTMLInputImage,(void **)&pImage);
if( pImage != NULL )
{
BSTR bValue;
pImage->get_src(&bValue);
CString src(bValue);
SysFreeString(bValue);
if(src.Find("btn_login_1.gif") != -1 )
{
pElem->click();
}
pImage->Release();
}
}
pElem->Release();
}
pDisp2->Release();
}
}
pColl->Release();
pHTMLDocument2->Release();//For the next page open a fresh document
pDisp->Release();
}