开发者

Handle to window handle

开发者 https://www.devze.com 2023-01-26 15:41 出处:网络
I\'ve tried using the \"grab all of the process IDs enumerated by the desktop\" method, however that doesn\'t work.

I've tried using the "grab all of the process IDs enumerated by the desktop" method, however that doesn't work.

  • Is there a way to convert a handle to a window handle? -or-
  • Is there a way to take a process ID and find out all of the child windows spawned by the process?

I don't want to use FindWindow 开发者_运维问答due to multiple process issues.


You could call EnumWindows() to iterate over all the top-level windows on the screen, then use GetWindowThreadProcessId() to find out which ones belong to your process.

For example, something like:

BOOL CALLBACK ForEachTopLevelWindow(HWND hwnd, LPARAM lp)
{
    DWORD processId;
    GetWindowThreadProcessId(hwnd, &processId);
    if (processId == (DWORD) lp) {
        // `hwnd` belongs to the target process.
    }
    return TRUE;
}

VOID LookupProcessWindows(DWORD processId)
{
    EnumWindows(ForEachTopLevelWindow, (LPARAM) processId);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消