窗口枚举的时候有时候怎么会举不到的
我枚举窗口的时候 大部分是能够枚举到的 可是有时候好象因为窗口在动什么的 他就枚举不到这个窗口 请问这是怎么回事 啊
[解决办法]
你的代码呢?
// 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;
}