首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

窗口枚举的时候有时候如何会举不到的

2012-03-21 
窗口枚举的时候有时候怎么会举不到的我枚举窗口的时候 大部分是能够枚举到的可是有时候好象因为窗口在动什

窗口枚举的时候有时候怎么会举不到的
我枚举窗口的时候 大部分是能够枚举到的 可是有时候好象因为窗口在动什么的 他就枚举不到这个窗口 请问这是怎么回事 啊

[解决办法]
你的代码呢?

// enumWnd.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <tlhelp32.h>

BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
/*if(GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)
return TRUE;
if(!(GetWindowLong(hWnd, GWL_STYLE) & WS_SYSMENU))
return TRUE;
if(!(GetWindowLong(hWnd, GWL_STYLE) & WS_VISIBLE))
return TRUE;*/

static int n = 0;
char szCaption[MAX_PATH];
GetWindowText(hWnd, szCaption, MAX_PATH);
printf("%d: %s\n", ++n, szCaption);

//GetClassName(hWnd, szCaption, MAX_PATH);
//printf("%s\n", szCaption);
//printf("%x\n", GetWindowLong(hWnd, GWL_STYLE));

DWORD dwProcId = 0;
GetWindowThreadProcessId(hWnd, &dwProcId);
HMODULE hModule = (HMODULE)CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcId);
MODULEENTRY32 me;
me.dwSize = sizeof(MODULEENTRY32);
Module32First(hModule, &me);
printf("\t(%s)\n", me.szExePath);

return TRUE;
}

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

return 0;
}

热点排行