太简单了
void GetInnerText(CString cs)
{
CoInitialize(NULL);  //初始化COM环境

//convert find word to widechar
int nFromLen=cs.GetLength()+1;
OLECHAR *szHTML;
szHTML= new OLECHAR[ nFromLen];
MultiByteToWideChar( CP_ACP, 0, cs, -1, szHTML, nFromLen);



IHTMLDocument2 *pDoc = NULL;


CoCreateInstance(CLSID_HTMLDocument, 
NULL, 
CLSCTX_INPROC_SERVER, 
IID_IHTMLDocument2, 
(LPVOID *) &pDoc);

if (pDoc)
{
IPersistStreamInit *pPersist = NULL;

pDoc->QueryInterface(IID_IPersistStreamInit, 
(LPVOID *) &pPersist);

if (pPersist)
{
IMarkupServices *pMS = NULL;

pPersist->InitNew();
pPersist->Release();

pDoc->QueryInterface(IID_IMarkupServices, 
(LPVOID *) &pMS);

if (pMS)
{
IMarkupContainer *pMC = NULL;
IMarkupPointer *pMkStart = NULL;
IMarkupPointer *pMkFinish = NULL;

pMS->CreateMarkupPointer(&pMkStart);
pMS->CreateMarkupPointer(&pMkFinish);

pMS->ParseString(szHTML, 
0, 
&pMC, 
pMkStart, 
pMkFinish);

if (pMC)
{
IHTMLDocument2 *pNewDoc = NULL;

pMC->QueryInterface(IID_IHTMLDocument, 
(LPVOID *) &pNewDoc);

if (pNewDoc)
{
// do anything with pNewDoc, in this case 
// get the body innerText.

IHTMLElement *pBody;
pNewDoc->get_body(&pBody);

if (pBody)
{
BSTR strText;

pBody->get_innerText(&strText);
pBody->Release();

CString s(strText);
if(s.IsEmpty())
s =_T("ÍøÒ³ÕýÎÄΪ¿Õ£¡");

SysFreeString(strText);
AfxMessageBox(s);
}

pNewDoc->Release();
}

pMC->Release();
}

if (pMkStart)
pMkStart->Release();

if (pMkFinish)
pMkFinish->Release();

pMS->Release();
}
}

pDoc->Release();
}

delete szHTML;
CoUninitialize();
}

解决方案 »

  1.   

    记得先:#include <mshtml.h>
      

  2.   

    为什么编译时  IMarkupServices' : undeclared identifier
      

  3.   

    先谢过这位鸟兄,嘻嘻
    但我也出现和地平线一样的状况,
    error C2065: 'IMarkupServices' : undeclared identifier
      

  4.   

    需要IE5头文件支持。.
    Stock Implementation mshtml.dll 
    Custom Implementation No 
    Inherits from IUnknown  
    Header and IDL files Mshtml.h, Mshtml.idl 
    Minimum availability Internet Explorer 5 
    Minimum operating systems Windows 95, Windows NT 4.0 
      

  5.   

    是吗,那究竟是要怎么做呀??你考的那些MSDN上的东西我也看见了,
      

  6.   

    头文件和库的下载地址:
    http://msdn.microsoft.com/downloads/samples/internet/libraries/ie55_lib/
    http://msdn.microsoft.com/downloads/samples/internet/libraries/ie6_lib/
    其中有安装帮助。
      

  7.   

    下载下来了,但还是不行,
    I:\Microsoft Visual Studio\VC98\INCLUDE\olectl.h(18): Could not find the file macocidl.h.下载了一大堆文件,不知道时需要那个文件了,
    看样子还得麻烦高手赐教了
      

  8.   

    倒~
    要换头文件包含顺序
    看看SDK的说明。
      

  9.   

    是什么顺序,SDK什么地方有说明???
      

  10.   

    option的directory的listBox上面有四个按钮啊一个表示新建,一个表示删除、剩下两个箭头就是调整头文件包含顺序的了。
      

  11.   

    请大家看看http://www.csdn.net/Expert/topic/422/422629.shtm
    难道真的没有人明白吗,连这都不明白,如何称得上高手? 
      

  12.   

    次序?下载的SDK头文件和库文件应该在上面。
      

  13.   

    我从新下载了一次,原来有一幅gif图片写明了次序,
    我第一次下载时以为是广告之类的,把它删掉了,
    还的我浪费那么多时间,谢谢各位了