窗口句柄的句柄 [英] Handle to window handle

查看:33
本文介绍了窗口句柄的句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过使用获取桌面枚举的所有进程 ID"方法,但是这不起作用.

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

  • 有没有办法将句柄转换为窗口句柄?-或者-
  • 有没有办法获取进程 ID 并找出该进程生成的所有子窗口?

由于多个进程问题,我不想使用 FindWindow.

I don't want to use FindWindow due to multiple process issues.

推荐答案

您可以拨打 EnumWindows() 遍历屏幕上的所有顶级窗口,然后使用 GetWindowThreadProcessId() 以找出哪些属于您的进程.

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.

例如,类似于:

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);
}

这篇关于窗口句柄的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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