我是为了在我的浏览器中(基于CHtmlview),做一个简单收藏夹的功能,就是把当前的网址和网页的名称,写入到ini文件中。比如,我在maxthon中,把网页:“http://topic.csdn.net/t/20031212/13/2556726.html”加入收藏夹时,在网页名称中将显示:“---200分,如何取得链接所属的网页url和该链接名称----- VC-MFC - 基础类 - CSDN社区 community.csdn.net”。我现在就是想获得网页名称“200分,如何取得链接所属的网页url和该链接名称----- VC-MFC - 基础类 - CSDN社区 community.csdn.net”,请告诉我具体的获得方法。我知道strURL是当前网址,但是这个网站简介,不知道什么怎么获得了。

解决方案 »

  1.   

    取得URL这样吧
    m_pBrowserApp->get_LocationURL(&bstrUrl);
      

  2.   

    先得到IHTMLDocument2
    然后IHTMLDocument2::get_title(BSTR *p);
    附:
    IHTMLDocument2::title PropertySets or gets the title of the document.Syntax    HRESULT IHTMLDocument2::get_title(BSTR *p);
        HRESULT IHTMLDocument2::put_title(BSTR v);Parameters    p
            Pointer to a variable of type BSTR that receives the title.
        v
            BSTR that specifies the title.Return Value    Returns S_OK if successful, or an error value otherwise.Res    The title identifies the contents of the document and is displayed in the header bar of the document window. This function sets or gets the TITLE object in the document header (defined by the HEAD object).
      

  3.   

    不是很明白 我是继承CHtmlview的,IHTMLDocument2类怎么得到??
      

  4.   

     IHTMLDocument2*   pHtmlDoc2   =   (IHTMLDocument2*)GetHtmlDocument();   
      

  5.   

    D:\webbrowser正确版\webbrowserView.cpp(187) : error C2065: 'IHTMLDocument2' : undeclared identifier
    D:\webbrowser正确版\webbrowserView.cpp(187) : error C2065: 'pHtmlDoc2' : undeclared identifier
    D:\webbrowser正确版\webbrowserView.cpp(187) : error C2059: syntax error : ')'
    Generating Code...
    要插入什么头文件??
      

  6.   

    头文件:
    #include <afxdhtml.h>
      

  7.   

    我想问问大家,一定要这么复杂才能获得网站名称吗?CHtmlview不是完整的实现了浏览网页的功能么?怎么连查看网站名称,这么基本的功能都没有??如果可以的话,我想通过CHtmlview来实现。
      

  8.   

    CHtmlview只是浏览网页的控件,他的标题是根据加载不同的页面而不同的,
    根据CHtmlview得到所加载网页的IHTMLDocument2才能得到标题。
      

  9.   

    其实是这样的,我知道html的源文件都是放在临时文件里的,我要读出title,要现读出网页的源代码,而后从源代码中找出title,既然网页能够显示出来了,我能不能想办法读出已存在我电脑内的临时文件呢,即源代码??
        还有,我用的是VC 6,网上说,都要自己写读title的函数的,你给我的函数,好像能直接获得title,但是msdn里面查不到,这怎么回事啊?
      

  10.   

    IHTMLDocument2::get_title(BSTR *p)在msdn里查不到啊,lion_wing
      

  11.   

    1、源文件应该有,那你就准备解析HTML吧
    2、http://msdn2.microsoft.com/en-au/library/aa752635(VS.85).aspx
      

  12.   

    大哥你给的是VC 2005的msdn,不过还是谢谢你的热心。