Enumerate IE windows using Shell fails in WH_JOURNALRECORD hook
I am trying to call the following code within a WH_GETMESSAGE hook procedure and it works fine. But the same piece of code fails inside a WH_JOURNALRECORD hook procedure. Can anyone help me in this regard.
void EnumIE()
{ CoInitialize( NULL );
SHDocVw::IShellWindowsPtr spSHWinds;
spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows));
long nCount = spSHWinds->GetCount();
IDispatchPtr spDisp;
for (long i = 0; i < nCount; i++)
{ _variant_t va(i, VT_I4);
spDisp = spSHWinds->Item(va);
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (spBrowser != NULL)
{ MSHTML::IHTMLDocument2Ptr spDoc(spBrowser->GetDocument());
if (spDoc != NULL)
{ HWND hWnd = NULL;
spBrowser->get_HWND ((long*)(&hWnd));
}
}
}
CoUninitialize();
}

