转载自csdn:http://blog.csdn.net/hairi/article/details/548064

 

EnumWindows 用来列举屏幕上所有顶层窗口。

MSDN原话:

The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window。

函数形式:

BOOL EnumWindows(
WNDENUMPROC
lpEnumFunc, // callback function
LPARAM lParam // application-defined value
);
其中 WNDENUMPROC 是回调函数,回调函数中写自己想做的操作,当调用EnumWindows的
时候,每次遇到一个窗口,系统就调用一次你的WNDENUMPROC ,然后把窗口句柄传给你。
EnumWindows 
 函数成功则返回非0值;
 函数失败则返回0值;
 EnumWindowsProc 返回0值,同样导致函数EnumWindows 返回0值。
 
另外,该函数不列举子窗口,除了几种拥有WS_CHILD 风格的系统所属窗口。
MSDN原话:
The EnumWindows function does not enumerate child windows,with the exception 
of a few top-level windows owned by the system that have the WS_CHILD style. 
使用举例:
先声明一个EnumWindowsProc ,比如:
BOOL CALLBACK EnumWindowsProc_1(HWND hwnd,LPARAM lparam) ;
然后实现此函数,写入自己想做的事情,比如:
BOOL CALLBACK EnumWindowsProc_1(HWND hwnd,LPARAM lparam)
{
 
Technorati 标签: C++
 ::GetWindowText(hwnd,lpWinTitle,256-1); 
CString m_strTitle;
m_strTitle.Format("%s",lpWinTitle);
if(m_strTitle.Find("Internet Explorer")!=-1)
{
  AfxMessageBox("这是一个IE窗口!") ;

return TRUE ;
}
然后就可以在其他地方调用EnumWindows的时候使用回调函数,比如:
::EnumWindows(EnumWindowsProc_1,0) ;
这样每当遇到IE窗口时,就会进行 提示“这是一个IE窗口!” 的操作。

EnumWindows 使用的更多相关文章

  1. EnumWindows function

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx Enumerates all top-l ...

  2. C#调用API函数EnumWindows枚举窗口的方法

    原文 http://blog.csdn.net/dengta_snowwhite/article/details/6067928 与C++不同,C#调用API函数需要引入.dll文件,步骤如下: 1. ...

  3. 在C#中调用Win32函数EnumWindows枚举所有窗口。

    原文 http://www.cnblogs.com/mfm11111/archive/2009/06/30/1514322.html 开发旺旺群发软件,难点及重要技术点分析(一) 一.        ...

  4. 使用API函数EnumWindows()枚举顶层窗口

      http://simpleease.blog.163.com/blog/static/1596085820052770290/ 要枚举Windows当前所有打开的顶层窗口,可使用Windows A ...

  5. Windows API 编程----EnumWindows()函数的用法

    1. 函数原型: BOOL WINAPI EnumWindows( _In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam); lpEnumFunc: 应用程序 ...

  6. win32gui.EnumWindows my.os.EnumWindows.py

    import win32guidef _MyCallback(hwnd, extra): windows = extra temp = [] temp.append(hex(hwnd)) temp.a ...

  7. 使用 EnumWindows 找到满足你要求的窗口

    原文:使用 EnumWindows 找到满足你要求的窗口 在 Windows 应用开发中,如果需要操作其他的窗口,那么可以使用 EnumWindows 这个 API 来枚举这些窗口. 本文介绍使用 E ...

  8. win32gui.EnumWindows

    python2 import win32gui, win32con, win32api import time, math, random def _MyCallback( hwnd, extra ) ...

  9. 使用 EnumWindows 找到满足你要求的窗口 - walterlv

    原文:使用 EnumWindows 找到满足你要求的窗口 - walterlv 使用 EnumWindows 找到满足你要求的窗口 2019-04-30 13:11 在 Windows 应用开发中,如 ...

随机推荐

  1. Electrification Plan(最小生成树)

    http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=50#problem/D 最小生成树模板,注意的是这里有k个发电站,它们不再需要连 ...

  2. CentOS 7下载地址(ISO文件)

    CentOS安装文件有两类(32位和64位),每类下载对应有不同的版本,这些版本适合不同需求的用户.CentOS 7官方下载地址:https://www.centos.org/download/在Ce ...

  3. ASP.NET学习路线图

    转自:http://www.cnblogs.com/huangmeimujin/archive/2011/08/08/2131242.html 如果你已经有较多的面向对象开发经验,跳过以下这两步: 第 ...

  4. HDU-2549 壮志难酬

    壮志难酬 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  5. Linux和Windows下的进程管理总结

    在Windows和Linux下都可以很方便地列出当前运行的进程.Windows下可以使用组合键CTRL+ALT+DEL打开任务管理器,在进程选项卡中就列举出了当前运行的所有进程,除此之外还可以在命令行 ...

  6. Bzoj 4034: [HAOI2015]T2 树链剖分,子树问题,dfs序

    4034: [HAOI2015]T2 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 1841  Solved: 598[Submit][Status] ...

  7. dp hdu-4433 locker

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4433 题目大意: 给两个长度相等的数字串s1,s2.每次操作可以把连续的最多三位都+1或-1,如果超 ...

  8. Y2K Accounting Bug

    题目: Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost som ...

  9. thinkphp如何写find_in_set这样的orm查询封装

    今天写thinkphp的orm封装的时候 需要写一个 select * from table where user_id=xxx and find_in_set(100,group_id)这样的SQL ...

  10. String和StringBuilder作为参数的区别

    先见下面实例: public class TestDemo { @Test public void test(){ //String str = "hello"; String s ...