HRESULT hr;
IDispatch *pDisp = GetHtmlDocument();
ASSERT( pDisp ); //if NULL, we failed// 获得Html文档指针
IHTMLDocument2 *pDocument = NULL;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pDocument );IHTMLElement *pBody = NULL;
hr = pDocument->get_body( &pBody );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pBody );// 从body获得IHTMLElement2接口指针,用以访问滚动条
IHTMLElement2 *pElement = NULL;
hr = pBody->QueryInterface(IID_IHTMLElement2,(void**)&pElement);
ASSERT(SUCCEEDED(hr));
ASSERT( pElement );// 向下滚动100个像素
pElement->put_scrollTop( 100 ); // 获得滚动条高度
long scroll_height; 
pElement->get_scrollHeight( &scroll_height );// 获得滚动条宽度
long scroll_height; 
pElement->get_scrollWidth( &scroll_width );// 获得滚动条位置,从顶端开始
long scroll_top;
pElement->get_scrollTop( &scroll_top );
这个代码前面执行都正常,到hr = pDocument->get_body( &pBody );这句后,pBody总是空值