CComPtr<IShellWindows> pShellWindows; pShellWindows.CoCreateInstance(CLSID_ShellWindows); if(pShellWindows) { long lShellWindowCount=0; pShellWindows->get_Count(&lShellWindowCount); for(long i = 0; i < lShellWindowCount; i++) { CComPtr<IDispatch> pdispShellWindow; pShellWindows->Item(CComVariant(i),&pdispShellWindow); CComQIPtr<IWebBrowser2> pIE(pdispShellWindow); if(pIE)//is it a Shell window? { HWND hforeground = GetForegroundWindow(); //is it the right type? LONG_PTR lwnd=NULL; pIE->get_HWND(&lwnd); HWND hwnd=reinterpret_cast<HWND>(lwnd); char className[_MAX_PATH];ZeroMemory(className, sizeof(className)); //HWND hwnd = GetTabWindow(pIE); ::GetClassName(hwnd, className ,_MAX_PATH); if(hforeground == hwnd && strcmp("IEFrame", className) == 0) { Here: } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)