用什么函数可以获得窗口的句柄?

解决方案 »

  1.   

    FindWindow
    EnumWindows
    都可以
      

  2.   

    如果你当前窗口为活动窗口
    也可以通过
    GetDesktopWindow( ); 获得窗口句柄
      

  3.   

    static CWnd* PASCAL FindWindow( LPCTSTR lpszClassName, LPCTSTR lpszWindowName );Return ValueIdentifies the window that has the specified class name and window name. It is NULL if no such window is found. The CWnd* may be temporary and should not be stored for later use.ParameterslpszClassNamePoints to a null-terminated string that specifies the window’s class name (a WNDCLASS structure). If lpClassName is NULL, all class names match.lpszWindowNamePoints to a null-terminated string that specifies the window name (the window’s title). If lpWindowName is NULL, all window names match.ResReturns the top-level CWnd whose window class is given by lpszClassName and whose window name, or title, is given by lpszWindowName. This function does not search child windows.
      

  4.   

    HWND GetSafeHwnd( ) const;