是否可以创建无法通过枚举找到的 win32 消息传递窗口?

Is it possible to create a win32 messaging window that won't be found by enumerating?

本文关键字:win32 消息传递 窗口 枚举 创建 是否      更新时间:2023-10-16

我正在尝试使用以下代码枚举所有win32窗口:

EnumChildWindows(GetDesktopWindow(),
                 WindowManager::enumChildWindows,
                 reinterpret_cast<LPARAM>(this));
BOOL CALLBACK WindowManager::enumChildWindows(HWND hwnd, LPARAM lParam) {
    WindowManager* manager = reinterpret_cast<WindowManager*>(lParam);
    //
    // Do stuff with child window handle (hwnd)
    //
    // Return TRUE to continue enumeration, FALSE to stop.
    return TRUE;
}

因此,基本上,我通过从WinAPI调用GetDesktopWindow( VOID )函数来获得最顶部的窗口,并通过再次从WinAPI中调用EnumChildWindows( __in_opt HWND hWndParent, __in WNDENUMPROC lpEnumFunc, __in LPARAM lParam)函数来枚举子窗口。

简单地说,我的问题是,通过这种方法,我能错过任何win32窗口吗?有人能隐藏win32窗口,使这种方法无法枚举它吗?

提前谢谢。

按照您的方式(通过EnumChildWindows(GetDesktopWindow)),这是可能的:只创建消息窗口。附言:但是您可以通过EnumChildWindows(GetAncestor(FindWindowEx(HWND_message,0,0,0),GA_PARENT)枚举仅消息窗口:请参阅FindWindow如何找到EnumChildWindows';t?。