EnumWindows遍历窗口

#include <vector>
using namespace std;


vector<HWND > m_hWnds;
BOOL EnumWindowsProc(HWND hWnd , LPARAM lParam )
{
    if (::GetWindowLong( hWnd, GWL_STYLE)& WS_VISIBLE)
    {
        char szClassName[128] = { 0 };
        if (::GetClassNameA( hWnd, szClassName, 128) != 0)
        {
            if (strcmp( "3DSMAX", szClassName) == 0)
            {
                m_hWnds.push_back( hWnd);
            }
        }

    }
    return TRUE;
}

int Get3dmaxWndCount()
{
    m_hWnds.clear();
    ::EnumWindows((WNDENUMPROC)EnumWindowsProc, NULL);

    return (int)m_hWnds.size();
}
本文为“技术点滴”的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注