主进程调用没问题呀,怎么一到线程就不行了?DWORD WINAPI threadtest(LPVOID lpParam)
{
CoInitialize(NULL);
CTest_mfcDlg * mfcdlg=(CTest_mfcDlg *)lpParam;
mfcdlg->m_webbrowser.Navigate("http://www.g.cn",0,0,0,0);
Sleep(1000*15);
//mfcdlg->m_webbrowser.Stop();
IHTMLDocument2 *pDoc = (IHTMLDocument2 *)mfcdlg->m_webbrowser.GetDocument();
IHTMLElementCollection * pElementCollection=NULL;
pDoc->get_all(&pElementCollection);//这里的问题
return 0;
}
{
CoInitialize(NULL);
CTest_mfcDlg * mfcdlg=(CTest_mfcDlg *)lpParam;
mfcdlg->m_webbrowser.Navigate("http://www.g.cn",0,0,0,0);
Sleep(1000*15);
//mfcdlg->m_webbrowser.Stop();
IHTMLDocument2 *pDoc = (IHTMLDocument2 *)mfcdlg->m_webbrowser.GetDocument();
IHTMLElementCollection * pElementCollection=NULL;
pDoc->get_all(&pElementCollection);//这里的问题
return 0;
}
{
CoInitialize(NULL);
CTest_mfcDlg * mfcdlg=(CTest_mfcDlg *)lpParam;
mfcdlg->m_webbrowser.Navigate("http://www.g.cn",0,0,0,0);
Sleep(1000*5);
HRESULT hr;
//mfcdlg->m_webbrowser.Stop();
IHTMLDocument2 *pDoc =NULL;
pDoc=(IHTMLDocument2 *)mfcdlg->m_webbrowser.GetDocument();
IHTMLElementCollection * pElementCollection=NULL;
hr=pDoc->get_all(&pElementCollection);
if(SUCCEEDED(hr))
{
::AfxMessageBox("error");//一直执行这一步
}
return 0;
}
pDoc=(IHTMLDocument2 *)GetDocument();
IHTMLElementCollection * pElementCollection=NULL;
hr=pDoc->get_all(&pElementCollection);
CWebBrowser2::OnNavigateComplete2(...)
{
ResetEvent(hEvent);
}threadset(...)
{
...
WaitForSingleObject(hEvent);
pDoc->get_all();
}
int WINAPI threadtest(LPVOID lpParam)
{
CoInitializeEx(0, 0);
CTinyIeDlg * mfcdlg=(CTinyIeDlg *)lpParam;
mfcdlg->m_Htm.Navigate(L"http://www.g.cn",0,0,0,0);
Sleep(1000*15);
//mfcdlg->m_webbrowser.Stop();
IHTMLDocument2 *pDoc = (IHTMLDocument2 *)mfcdlg->m_Htm.GetHtmlDocument();
IHTMLElementCollection * pElementCollection=NULL;
pDoc->get_all(&pElementCollection);//这里的问题
return 0;
}
我的只有GetDocument()呀
你们用的什么版本的?
我直接在VC6中插入的,装的IE7浏览器
为什么pDoc->get_frames(&pFramesCollection); 报错
pDoc->get_all(&pElementCollection); 没事?
并且
long num;
pElementCollection->get_length(&num);
还能正确显示出有多少节点
{
CoInitializeEx(0, 0);
CTinyIeDlg * mfcdlg=(CTinyIeDlg *)lpParam;
mfcdlg->m_Htm.Navigate(L"http://www.g.cn",0,0,0,0);
Sleep(1000*15);
//mfcdlg->m_webbrowser.Stop();
IHTMLDocument2 *pDoc = (IHTMLDocument2 *)mfcdlg->m_Htm.GetHtmlDocument();
IHTMLElementCollection * pElementCollection=NULL;
pDoc->get_all(&pElementCollection);//这里的问题 IHTMLFramesCollection2 * pFramesCollection;
pDoc->get_frames(&pFramesCollection); return 0;
}
int WINAPI threadtest(LPVOID lpParam)
{
CoInitializeEx(0, 0);
CTinyIeDlg * mfcdlg=(CTinyIeDlg *)lpParam;
mfcdlg->m_Htm.Navigate(L"http://www.g.cn",0,0,0,0);
Sleep(1000*15);
//mfcdlg->m_webbrowser.Stop();
IHTMLDocument2 *pDoc = (IHTMLDocument2 *)mfcdlg->m_Htm.GetHtmlDocument();
IHTMLElementCollection * pElementCollection=NULL;
pDoc->get_all(&pElementCollection);//这里没问题 IHTMLFramesCollection2 * pFramesCollection;
pDoc->get_frames(&pFramesCollection);//运行到这就报错 return 0;
}