gpt4 book ai didi

c++ - 将当前窗口的句柄获取到 GetWindowText?

转载 作者:行者123 更新时间:2023-11-28 08:12:09 25 4
gpt4 key购买 nike

我想显示对话框的标题:

HWND hWnd = ::GetActiveWindow();
char cc[101];
::GetWindowText(hWnd,cc,100);
MessageBox(cc);

但结果是一个空白的“”。

不知道哪里出了问题??

最佳答案

根据 MSDN :

Retrieves the window handle to the active window attached to the calling thread's message queue.

这意味着如果您从中调用该函数的线程不拥有任何窗口,该函数将失败。

你可能想要 GetForegroundWindow相反。

关于c++ - 将当前窗口的句柄获取到 GetWindowText?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8767248/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com