已知IWebBrowser2接口,如何获得其Internet Explorer_Server窗口句柄?

来源:互联网 发布:java如何清空文件内容 编辑:程序博客网 时间:2024/05/17 02:18

关键字:IWebBrowser2,HWND,::GetCursorPos,::ScreenToClient

方法:

HRESULT IWebBrowser2::get_HWND(long *pHWND);

代码:

#include <shlguid.h>

IServiceProvider* pServiceProvider = NULL;
if (SUCCEEDED(pWebBrowser2->QueryInterface(
    IID_IServiceProvider,
    (void**)&pServiceProvider)))
{
    IOleWindow* pWindow = NULL;
    if (SUCCEEDED(pServiceProvider->QueryService(
        SID_SShellBrowser,
        IID_IOleWindow,
        (void**)&pWindow)))
    {
        HWND hwndBrowser = NULL;
        if (SUCCEEDED(pWindow->GetWindow(&hwndBrowser)))
        {
            // hwndBrowser is the handle of TabWindowClass
        }

        pWindow->Release();
    }

    pServiceProvider->Release();
}

参考:http://msdn.microsoft.com/en-us/library/aa752126.aspx

http://topic.csdn.net/u/20070301/11/91d45328-4985-4a16-8ccf-b58b2423e8a2.html

0 0
原创粉丝点击