如何找到当前进程的对话框句柄? [英] How to find the dialog handle of the current process?
问题描述
我正在研究CAD插件应用程序。在该应用程序中,我调用了一个对话框,当前查找对话框句柄的方法是 FindWindow() 方法,其中
工作正常。但这不合适,因为此函数正在所有打开的进程中搜索指定的标题。因此,检索到的句柄可能来自另一个进程。打开CAD应用程序的许多实例时,这会导致许多问题。
我们必须找到一种方法来查找当前进程的此对话框句柄或使用当前进程ID更改对话框标题。是否有可能达到上述要求?如果可能,请告诉我。提前致谢。
推荐答案
您可以使用 GetWindowThreadProcessId函数 确定与FindWindow返回的窗口句柄相关联的进程。
You can use GetWindowThreadProcessId function to determine the process associated with the window handle returned by FindWindow.
但是,当存在多个具有相同类/标题的窗口时,FindWindow可能不会返回所需的窗口句柄。 您可以使用
EnumWindows功能枚举窗口,以便您可以检查枚举中返回的每个窗口句柄,以获取所需的窗口类/标题和进程ID。
However, FindWindow may not return the desired window handle when more than one window with the same class/title exist. You can use
EnumWindows function to enumerate windows so that you can check each window handle returned in the enumeration for the desired window class/title and process id.
这篇关于如何找到当前进程的对话框句柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!