您的位置:首页 > 其它

枚举当前打开的所有窗口

2011-02-15 11:09 225 查看
#include <Stdio.h>
#include <Windows.h>

BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);

int main( int argc, char* argv[] )
{
EnumWindows( EnumWindowsProc, NULL );
return 0;
}

HWND m_hwndFind[1000] = {0};
int  m_num = 0;

BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
if(::GetWindowLong(hWnd,GWL_STYLE) & WS_VISIBLE)
{
char sBuf[256];

//获取窗口标题
::GetWindowText( hWnd, sBuf, 256 );
if ( strcmp( sBuf, "我的电脑" ) == 0 )
{
//在发现我的电脑时设置其标题为www.a3gs.com
::SetWindowText( hWnd, "www.a3gs.com" );
}
printf( "%s\n", sBuf );
m_hwndFind[m_num] = hWnd;
m_num++;
}
return 1;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: