如何停止EnumWindows无限运行win32 [英] How to stop EnumWindows running infinitely win32

查看:904
本文介绍了如何停止EnumWindows无限运行win32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码一直工作。不知何故,我设法让Visual C ++ Express不会在最终返回语句上的断点,它似乎永远运行。

The code worked all along. Somehow I manage to get Visual C++ Express not hit the break point on the final return statement and it appeared to run for ever.

在示例代码中,EnumWindows枚举无限。
如何在所有窗口被枚举后停止。

In the example code bellow EnumWindows enumerates infinitely. How can one make it stop after all windows has been enumerated.

#include <Windows.h>

BOOL CALLBACK EnumWindowsProc(HWND hWnd, long lParam) {
    TCHAR buff[255];

    if (IsWindowVisible(hWnd)) {
    	GetWindowText(hWnd, (LPWSTR) buff, 254);
    	printf("%S\n", buff);
    }
    return TRUE;
}

int _tmain(int argc, _TCHAR* argv[]) {
    EnumWindows(EnumWindowsProc, 0);
    return 0;
}


推荐答案

一旦我删除了宽字符的东西,并添加 #include< stdio.h> 获得printf()声明。

Your code works for me, once I removed the wide-character stuff and added #include <stdio.h> to get the printf() declaration. What output does it produce on your system?

对我有用的代码是:

#include <windows.h>
#include <stdio.h>

BOOL CALLBACK EnumWindowsProc(HWND hWnd, long lParam) {
    char buff[255];

    if (IsWindowVisible(hWnd)) {
        GetWindowText(hWnd, (LPSTR) buff, 254);
        printf("%s\n", buff);
    }
    return TRUE;
}

int main() {
    EnumWindows(EnumWindowsProc, 0);
    return 0;
}

这篇关于如何停止EnumWindows无限运行win32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆