Get the window’s handle(hwnd) in ie6/ie7 (bho,vb6)
Private Function GetIeTabHwnd(Optional URL As Variant) As Long
On Error GoTo Errs
Dim pUnk As olelib.IUnknown
Dim IServiceProvider As olelib.IServiceProvider
Dim IID_IServiceProvider As olelib.UUID
Dim SID_SShellBrowser As olelib.UUID
Dim IID_IOleWindow As olelib.UUID
Dim pow As olelib.IOleWindow
Dim anHwnd As Long
anHwnd = 0
If Not URL = "about:blank" Then ‘if is about:blank,get error
Debug.Print "URL is"; CStr(URL)
anHwnd = 0
Set pUnk = m_objIE
CLSIDFromString IIDSTR_IServiceProvider, IID_IServiceProvider
CLSIDFromString SIDSTR_SShellBrowser, SID_SShellBrowser
CLSIDFromString "{00000114-0000-0000-C000-000000000046}", IID_IOleWindow
pUnk.QueryInterface IID_IServiceProvider, IServiceProvider
IServiceProvider.QueryService SID_SShellBrowser, IID_IOleWindow, pow
anHwnd = pow.GetWindow ‘tabwindow hwnd
End If
GetIeTabHwnd = anHwnd
Bye:
Exit Function
Errs:
GetIeTabHwnd = 0
Resume Bye
End Function