천객만래 [千客萬來] (It has an interminable succession of visitors)

인터넷 익스플로러 윈도우 핸들 구하기는 어려운 게 아닌 만큼 별로 설명이 필요 없을 듯 하다.

버전에 따라 다르기는 하지만 우선 아래의 소스로 구해보면 감은 잡을 수 있을 것이다.


HWND hIEWnd;
 HWND hChildWnd;


 hIEWnd = FindWindow(_T("IEFrame"), NULL);
 
 hChildWnd = FindWindowEx(hIEWnd, 0, _T("Shell DocObject View"), NULL);

 //익스플로러 버전마다 틀리므로 아래의 체크를 거쳐야 합니다.
    if(hChildWnd == 0)
 {
        hChildWnd = FindWindowEx(hIEWnd, 0, _T("TabWindowClass"), NULL);
  
        if(hChildWnd == 0)
  {
   hChildWnd = FindWindowEx(hIEWnd, 0, _T("Frame Tab"), NULL);
   
            hChildWnd = FindWindowEx(hChildWnd, 0, _T("TabWindowClass"), NULL);
        }
  hChildWnd = FindWindowEx(hChildWnd, 0, _T("Shell DocObject View"), NULL);
 }
 if (hChildWnd != 0)
  hChildWnd = FindWindowEx(hChildWnd, 0, _T("Internet Explorer_Server"), NULL);




Posted by SB패밀리
// 탭브라우저에서 ActiveX가 포함된 웹페이지 핸들 찾기

BOOL CALLBACK EnumIEServer(HWND hwnd, LPARAM lParam)
{
    char szClassName[MAX_PATH];
    GetClassName(hwnd, szClassName, MAX_PATH-1);
    HWND *phWnd = (HWND *)lParam;

    if(strcmp(szClassName, "Internet Explorer_Server") == 0)
    {
        *phWnd = hwnd;
        return FALSE;
 }

 return TRUE;
}

HWND GetIEPage()
{
HWND hIEServer = NULL;
IServiceProvider* psp;
hr = m_pWeb->QueryInterface( IID_IServiceProvider, (void**)&psp );
 
if( SUCCEEDED(hr) && psp )  
{
 IOleWindow* pow; 
 psp->QueryService( SID_SShellBrowser, IID_IOleWindow, (void**)&pow ); 
 if( SUCCEEDED(hr) && pow)
 {   
   HWND hWnd = NULL; 
   hr = pow->GetWindow( &hWnd );
   if( SUCCEEDED(hr) && hWnd )
   {
  //hWnd is the handle of TabWindowClass 
  EnumChildWindows(hWnd, EnumIEServer, (LPARAM)&hIEServer);
   }
   pow->Release();  
 }
 psp->Release();                           
}
return hIEServer;
 }
Posted by SB패밀리

쌈꼬쪼려 소백촌닭


 HWND hIEWnd;
 HWND hChildWnd;


 hIEWnd = FindWindow(_T("IEFrame"), NULL);
 
 hChildWnd = FindWindowEx(hIEWnd, 0, _T("Shell DocObject View"), NULL);

 //익스플로러 버전마다 틀리므로 아래의 체크를 거쳐야 합니다.
    if(hChildWnd == 0)
 {
        hChildWnd = FindWindowEx(hIEWnd, 0, _T("TabWindowClass"), NULL);
  
        if(hChildWnd == 0)
  {
   hChildWnd = FindWindowEx(hIEWnd, 0, _T("Frame Tab"), NULL);
   
            hChildWnd = FindWindowEx(hChildWnd, 0, _T("TabWindowClass"), NULL);
        }
  hChildWnd = FindWindowEx(hChildWnd, 0, _T("Shell DocObject View"), NULL);
 }
 if (hChildWnd != 0)
  hChildWnd = FindWindowEx(hChildWnd, 0, _T("Internet Explorer_Server"), NULL);

 

Posted by SB패밀리