转载自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. Oracle core03_ACID

    ACID特性 oracle如何使用undo和redo来保证了关系数据库的ACID特性. ACID的特性简单描述为: Atomic:以事务为单位的原子性 Consistency:保证数据一致性 Isol ...

  2. statspack系列3

    原文:http://jonathanlewis.wordpress.com/2006/12/27/analysing-statspack-3/ 作者:Jonathan Lewis 下面的例子中的结果并 ...

  3. 汉企C#面向对象——继承

    public class Shengwu { private string _Name; public string Name { get { return _Name; } set { _Name ...

  4. 【转】 Android快速开发系列 10个常用工具类 -- 不错

    原文网址:http://blog.csdn.net/lmj623565791/article/details/38965311 转载请标明出处:http://blog.csdn.net/lmj6235 ...

  5. 机器更换登录密码重启,然后SQL Server登录不了

    解决方法:

  6. Web开发需要关注的技术细节

    摘要:在网站发布前,开发者需要关注有许多的技术细节,比如接口设计.用户体验.安全性.Web标准.性能.SEO等,倘若一个疏忽就会影响到整体的体验效果.作为一名Web开发者,哪些技术细节需要考虑呢? [ ...

  7. 转载: Asp.net常见word,excel,ppt,pdf在线预览方案

    参考链接: http://www.cnblogs.com/wolf-sun/p/3569960.html

  8. Bzoj 3747: [POI2015]Kinoman 线段树

    3747: [POI2015]Kinoman Time Limit: 60 Sec  Memory Limit: 128 MBSubmit: 553  Solved: 222[Submit][Stat ...

  9. 基于TCP协议的服务器(单线程)

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import  ...

  10. 简单的ALloctor模板

    template <typename T>class Alloctor{private: typedef T* address; T *memory,*t; size_t total_si ...