我尝试通过扩展程序使用IE窗口并搜索有关此内容的一些信息。我找到了下一个代码:
IShellWindowsPtr m_spSHWinds;
m_spSHWinds.CreateInstance(__uuidof(ShellWindows));
IDispatch *spDisp;
for (long i = 0; i < nCount; i++)
{
_variant_t va(i, VT_I4);
hR = m_spSHWinds->Item(va, &spDisp);
IHTMLWindow2 *pWnd= NULL;
IWebBrowser2 *spBrowser = NULL;
hR =spDisp->QueryInterface(IID_IWebBrowser2, (void**)&spBrowser);
if (spBrowser != NULL)
{
CString csString;
////
BSTR *str = (BSTR*)malloc(_MAX_PATH);
hR = spBrowser->get_LocationName(str);
IDispatch *sDis;
IHTMLDocument2 *spDoc = NULL;
hR = spBrowser->get_Document((IDispatch**)&sDis);
hR = sDis->QueryInterface(IID_IHTMLDocument2, (void**)&spDoc);
if(hR == S_OK)
{
BSTR p;
hR = spDoc->get_URL(&p);
TRACE("\n%s", p);
hR = spDoc->get_parentWindow(&pWnd);
if(hR == S_OK)
{
CString code,lang;
code.Format("var editcount = document.getElementsByTagName('input');"
"var count = 0;"
"for(var cpt = 0; cpt < editcount.length; cpt++){"
"if (editcount[cpt].type == 'text')"
" editcount[cpt].value = \"xxxx\";"
"else if(editcount[cpt].type == \"password\")"
" editcount[cpt].value = \"xxx\";"
"else if(editcount[cpt].type == \"hidden\")"
" editcount[cpt].value = \"xxx\";"
"else if(editcount[cpt].type == \"email\")"
" editcount[cpt].value = \"XXX@gmail.com\";"
"}");
lang.Format("javascript");
VARIANT v;
hR = pWnd->execScript(code.AllocSysString(),
lang.AllocSysString(), &v);
if(hR == S_OK)
{
TRACE("%s", str);
}
}
}
}
}
我想我可以通过这个获得所有标签,但我不知道这个库是什么以及如何在我的visual studio项目中添加它? 我用谷歌搜索,看到这使用shdocvw.dll但我在哪里可以找到填充和如何添加项目? 对不起英语不好,我希望有所帮助,谢谢