您的位置:首页 > 其它

枚举当前打开的所有窗口

2011-04-02 16:24 197 查看
BOOL  CAllwindowsDlg::EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
//be sure the current window is visible
if(::GetWindowLong(hWnd,GWL_STYLE)& WS_VISIBLE)
{
m_hwndFind[m_num] = hWnd;//record the HWND handle into array
m_num++;//count start
}
return 1;
}


11

void CAllwindowsDlg::OnButton3()
{
m_num = 0;
m_list.ResetContent();
::EnumWindows(CAllwindowsDlg::EnumWindowsProc,NULL);
for(int i = 0;i <=m_num;i++)
{
HWND m_wnd = m_hwndFind[i];
::GetWindowText(m_wnd,m_store,128);
::GetClassName(m_wnd,m_strClass,MAX_PATH-1);
m_winname[i] = m_store;
sprintf(m_name,"(%d)标题名称:",i);
strcat(m_name,m_store);
strcat(m_name,"      类名称:");
strcat(m_name,m_strClass);
m_list.AddString(m_name);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: