CoInitialize(NULL);
 
CComPtr<IPersistFile> pFile;
HRESULT hr;
 
hr=pFile.CoCreateInstance(CLSID_HTMLDocument);
if (!SUCCEEDED(hr))
{
}
 
if(!pFile)
{
}
hr=pFile->Load(L"E:\\2.htm", STGM_READ);
if (!SUCCEEDED(hr))
{
}
 
CComQIPtr<IHTMLDocument2> pDoc(pFile);
 
CComQIPtr<IHTMLElementCollection> pColl;
 
hr=pDoc->get_all(&pColl);
if (!SUCCEEDED(hr))
{
}
 
long count=-1;
hr=pColl->get_length(&count);
if (!SUCCEEDED(hr))
{
}
 
long elementCount=count;
网页里明明有元素的,怎么老是elementCount为0呢?哪里写错了?