I think the code is supposed to work on top level IWebBrowser2 objects. You can read more about top browser objects in my previous article.#include <shlguid.h>
HWND GetTabWnd(CComQIPtr<IWebBrowser2> spBrowser)
HWND hwndTab = NULL;
CComQIPtr<IServiceProvider> spServiceProvider = spBrowser;
if (spServiceProvider != NULL)
This technique was successfully implemented and tested in Twebst web automation library.