对于第一个问题,你可以搜索“如何获得IE地址栏的地址?”这个问题。
第二个问题,还是可以通过搜索得到答案的,见问题“如何获得当前控件的ID?”

解决方案 »

  1.   

    如果仅仅是希望取得ie地址栏的输入,那么可以这样:
    在DLL中安装一个鼠标钩子,用GetWindowFromPoint得到鼠标指向的窗口,判断是浏览器的地址栏就GetWindowText,如何判断用spy看看浏览器的地址栏的属性
    附上一篇贴子
    主  题:IE编程:如何得到IE当前显示的HTML文件?
    作  者:limz
    所属论坛:Visual C++
    问题点数:50
    回复次数:3
    发表时间:2000-11-11 15:00:00
     
    如何得到IE当前显示的HTML文件?
    我在微软站点上看到,要写一个com程序,须实现IObjectWithSite。
    原文:
    (If your COM object needs to access the DHTML Object Model of the page that Internet Explorer is currently displaying, you must implement IObjectWithSite.
    ...
    When IObjectWithSite is implemented, Internet Explorer will call IObjectWithSite::SetSite and pass it a pointer to IShellBrowser.

    但是从IShellBrowser又该怎样写才能得到当前显示的HTML文件?
    IObjectWithSite::SetSite(IUnknown *pUnkSite)
    {}
    先谢谢各位!(也请edyang兄再来看看这个问题!多谢!)
     
    回复贴子: 
    回复人:edyang(2000-11-11 16:01:00)  得30分 
    (edyang 的脸先是红了一下,但很快就恢复了正常,一本正经的说)
    嘿嘿,看来老兄世行内高手,献丑献丑。我想你能不能从 pUnkSite 的到 IHTMLDocument 的接口呢?如果能得到的话,一切问题就解决。由于本人时间有限,没有做实验:HRESULT      hr;
    IHTMLDocument *pIHTMLDoc;hr = pUnkSite->QueryInterface(IID_IHTMLDocument, (void **)&pIHTMLDoc);
    if(SUCCEEDED(hr))
    {
    _com_ptr_t(pIHTMLDoc) ptrDoc;hr = ptrDoc.QueryInterface(IID_IPersistStreamInit, &pPersistStream);
    if(pPersistStream == NULL)
    return;
    if(FAILED(pPersistStream->GetSizeMax(&uli)))
    {
    pPersistStream->Release();
    return;
    }
    //if(uli.LowPart == 0)
    //{
    //pPersistStream->Release();
    //return;
    //}uli.LowPart = 65536;
    hMem = ::GlobalAlloc(GPTR, uli.LowPart);
    if(hMem == NULL)
    {
    pPersistStream->Release();
    return;
    }hr = ::CreateStreamOnHGlobal(hMem, TRUE, &pStream);
    if(FAILED(hr))
    {
    pPersistStream->Release();
    ::GlobalFree(hMem);
    return;
    }
    hr = pPersistStream->Save(pStream, TRUE);AfxMessageBox((LPCTSTR)hMem);hr = pPersistStream->Release();
    pStream->Release(); 

     
    回复人:limz(2000-11-11 16:52:00)  得0分 
    to edyang兄:
    我试过了不能从 pUnkSite 的到 IHTMLDocument 的接口。还有没有其他的接口? 
     
    回复人:edyang(2000-11-11 17:12:00)  得20分 
    哦,试一试 IHTMLDocument2 怎样?MSDN 对 IShellBrowser 的解释是:
    The IShellBrowser interface is exposed by Windows Explorer and the Open File common dialog box to provide services for namespace extensions. 我想你可能在做一个对 Windows Explorer 的扩展?或者是镶嵌在 IE 里面的 COM(ActiveX)控件?