转载自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. FFT小结

    先上模板 #include<cstdio> #include<cmath> <<)*+; typedef long long ll; ll power(ll t,; ...

  2. Java中文乱码解决

    Jvm内部编码采用的是Unicode编码. 常见的字符编码集:ASCII编码,GBK编码,Unicode编码 UTF-8只是unicode的实现方式之一: UTF-8最大的一个特点,就是它是一种变长的 ...

  3. (转载)AS3.0实例学习 熟悉新的事件机制和addChild的运用

    (转载)http://www.jb51.net/article/13139.htm 首先声明:本人大菜鸟一个,刚接触AS3不久,许多理念还没来得及灌输,这些case都是从网上down的,但因为解说是英 ...

  4. (转载)Linux上iptables防火墙的基本应用教程

    (转载)http://www.vpser.net/security/linux-iptables.html iptables是Linux上常用的防火墙软件,下面vps侦探给大家说一下iptables的 ...

  5. MySqlCommand, MySqlParameter and "LIKE" with Percent Symbol

    //Wrong way MySqlCommand cmd = oldDb.GetSqlStringCommand(CommandType.Text,"SELECT * _ FROM user ...

  6. Unity 官方 Demo: 2DPlatformer 的 SLua 版本。

    9月份时,趁着国庆阅兵的假期,将 Unity 官方 Demo: 2DPlatformer 移植了一个 SLua 版本,并放在了我的 GitHub 账号下:https://github.com/yauk ...

  7. bzoj 1027 [JSOI2007]合金(计算几何+floyd最小环)

    1027: [JSOI2007]合金 Time Limit: 4 Sec  Memory Limit: 162 MBSubmit: 2970  Solved: 787[Submit][Status][ ...

  8. .net常見面試題(四)

    1. .Net.C#.VisualStudio之间的关系是什么? .Net一般指的是.Net Framework,提供了基础的.Net类,这些类可以被任何一种.Net编程语言调用,.Net Frame ...

  9. show drop down menu within/from action bar

    show drop down menu within/from action bar */--> pre { background-color: #2f4f4f;line-height: 1.6 ...

  10. 借助bool判断使冒泡排序效率提高

    排序问题是编程中最常见的问题.实际应用中,计算机有接近一半时间是在处理有关数据排列的问题,提高排序的效率有助于更快地解决问题. 先来说说平常一般的冒泡算法,使用两个循环,外循环作为整体排序,每趟循环使 ...