检索Delphi窗口句柄
我正在尝试从外部应用程序获取Delphi应用程序的窗口句柄。我可以看到有几个窗口创建(TApplication,TFrmMain等等),而且我知道TApplication是控制器,但是从不可见。但是,我可以看到真正的窗口的价值是什么?我知道这是TFrmMain(对于这个具体的应用程序),但是有可能实际上把它弄出来吗?信息是否存储在窗口属性中或其他位置?谢谢!
I am trying to get the window handles to a Delphi application from an external application. I can see that there are a few windows created (TApplication, TFrmMain and a few others), and I know that TApplication is the "controller", but never visible. However, can I read what the value for the real window is? I know that it is TFrmMain (for this specific application), but is it possible to actually figure this out somehow? Is the information stored in the window properties,or somewhere else? Thanks!
不,没有记录的方法来发现哪些窗口代表 Application.MainForm
从应用程序外部。在较新版本的Delphi中,主窗体的句柄不一定是 Application.MainForm.Handle
应用程序可以处理 OnGetMainFormHandle
事件返回任何他们想要的 - 用于选择模式对话框的父窗口。
No, there is no documented way to discover which of the windows represents Application.MainForm
from outside the application. In newer versions of Delp the main form's window handle isn't necessarily Application.MainForm.Handle
anyway; applications can handle the OnGetMainFormHandle
event to return whatever they want — that's used for choosing the parent window for modal dialogs.
你可以通过在他们的类名中找到具有main的窗口,但是即使你找到一个,也不能保证只有一个实例。应用程序可以有多个顶级窗口,在这种情况下,将其中任何一个指定为主窗口并不太有意义。
You can guess by looking for windows with "main" in their class names, but even if you find one, there's no guarantee that there's only one instance of it. Applications can have multiple top-level windows, in which case it doesn't make much sense to designate any one of them as the "main" one.