运行了下程序崩溃了。win7直接提示已停止工作。怎么办啊

来源:互联网  时间:2016/7/26 13:43:55

关于网友提出的“ 运行了下程序崩溃了。win7直接提示已停止工作。怎么办啊”问题疑问,本网通过在网上对“ 运行了下程序崩溃了。win7直接提示已停止工作。怎么办啊”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 运行了下程序崩溃了。win7直接提示已停止工作。怎么办啊
描述:

m_web.Navigate("http://1.1.1.2/srun_portal.html?userip=10.56.9.99&userurl=http://www.baidu.com&ac_id=2&sys=",NULL,NULL,NULL,NULL); 
HRESULT hr;
VARIANT index;
IDispatch *pDisp;
pDisp = m_web.GetDocument(); //m_web是控件型变量
IHTMLDocument2* pDoc; //文档接口
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
 
IHTMLElementCollection* pColl = NULL;                //枚举网页元素
 
hr = pDoc->get_all( &pColl );
 
LONG elementcount;
hr = pColl->get_length( &elementcount );//Find the count of the elements
for ( int i=0; i< elementcount; i++ )//Loop through each elment
{
IDispatch* pDisp2;
 
V_VT(&index) = VT_I4;
V_I4(&index) = i;
hr = pColl->item( index,index, &pDisp2 );//Get an element
 
if ( hr == S_OK )
{
IHTMLElement* pElmt;         //网页元素
hr = pDisp2->QueryInterface(IID_IHTMLElement,(void **)&pElmt );
if ( hr == S_OK )
{
BSTR bstr = SysAllocString(L"");
pElmt->get_id(&bstr); //获得网页元素id
pElmt->Release();
}
pDisp2->Release();
}
}
 
pColl->Release();
pDoc->Release();
pDisp->Release();

解决方案1:

在DocumentComplete事件中获取页面DOM内容来处理

解决方案2:

刚调用完Navigate不能使用GetDocument()方法,应该在DocumentComplete事件中调用

上一篇C++P2P的节点管理
下一篇DisconnectEx用法疑惑:只能用来主动关闭客户端连接?还是可以“客户端主动关闭连接”后DisconnectEx该客户端对应SOCKET?
明星图片
相关文章
《 运行了下程序崩溃了。win7直接提示已停止工作。怎么办啊》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)