vc中怎么检测是否正在使用IE或具有IE内核的浏览器
vc中如何检测是否正在使用IE或具有IE内核的浏览器?
vc中如何检测是否正在使用IE或具有IE内核的浏览器?求高手解答。。。
------解决方案--------------------
vc中如何检测是否正在使用IE或具有IE内核的浏览器?求高手解答。。。
------解决方案--------------------
- C/C++ code
CoInitialize(NULL); long nRelNum = 0; SHDocVw::IShellWindowsPtr m_spSHWinds; if (m_spSHWinds == NULL) { if(m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) != S_OK) { MessageBox(L"Failed"); CoUninitialize(); return ;//nRelNum; } } long nCount = m_spSHWinds->GetCount(); IDispatchPtr spDisp; for (long i = 0; i < nCount; i++) { _variant_t va(i, VT_I4); spDisp = m_spSHWinds->Item(va); SHDocVw::IWebBrowser2Ptr spBrowser(spDisp); BSTR name = SysAllocString(L""); spBrowser->get_FullName(&name); if (spBrowser != NULL) { IDispatchPtr spDisp; if(spBrowser->get_Document(&spDisp) == S_OK && spDisp != 0 ) { CComQIPtr<IHTMLDocument2> pDoc; CComQIPtr<IHTMLElementCollection> pElemAll; spDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc); if(pDoc==NULL) { continue; nRelNum++; } pDoc->get_all(&pElemAll); long count = 0; pElemAll->get_length(&count); for(int j=0;j<count;j++) { IDispatchPtr pElemDis; CComQIPtr<IHTMLElement> pElemItem; pElemAll->item(CComVariant(j),CComVariant(),&pElemDis); pElemDis->QueryInterface(IID_IHTMLElement,(void**)&pElemItem); BSTR out = SysAllocString(L""); pElemItem->get_innerText(&out); ShowText(out,StateEditCtr); SysFreeString(out); } } } } CoUninitialize(); return;