简体   繁体   English

枚举外部应用程序中的VCL控件

[英]Enumerate the VCL controls in a external application

is possible via the Windows API's to enumerate and iterate the VCL controls on a form (TForm) belonging to a external Win32 application written in C ++ Builder or Delphi. 可以通过Windows API枚举和迭代窗体(TForm)上的VCL控件,该窗体属于以C ++ Builder或Delphi编写的外部Win32应用程序。

Bye. 再见

No. First of all, consider that the Windows API has no idea what the "VCL" is. 否。首先,请考虑Windows API不知道“ VCL”是什么。 It doesn't know "TButton" or "TStringGrid," and it certainly doesn't know "TImage" or "TLabel," which don't even have window handles. 它不知道“ TButton”或“ TStringGrid”,当然也不知道甚至没有窗口句柄的“ TImage”或“ TLabel”。

You could use EnumChildWindows to get handles to the windowed controls. 可以使用EnumChildWindows获取窗口控件的句柄。 You could look at their class names to determine that they came from "TButton" or "TStringGrid," but even then, you would not have access to any object-related facilities. 您可以查看它们的类名来确定它们来自“ TButton”或“ TStringGrid”,但是即使那样,您也将无法访问任何与对象相关的功能。 You wouldn't have an object reference, and so you could not read any properties or call any methods. 您将没有对象引用,因此无法读取任何属性或调用任何方法。

TestComplete , from Automated QA, offers access to a program's forms and classes from an external program, which sounds like what you might be trying to do. 来自自动QA的TestComplete可从外部程序访问程序的形式和类,这听起来像您可能正在尝试做的事情。 It works by having a unit that you include in the Delphi program, and that unit essentially provides a back door for the TestComplete program to use to query the program's internals. 它通过在Delphi程序中包含一个单元来工作,该单元实质上为TestComplete程序提供了后门,可用于查询程序的内部。 That requires cooperation from the application developer; 这需要应用程序开发人员的合作; you can't sic TestComplete on an arbitrary program. 您不能在任意程序上使用TestComplete。

You could look at the DFMs, which are stored as resources in the executable. 您可以查看DFM,这些DFM作为资源存储在可执行文件中。

Anders Ohlsson put together a VCL Scanner application that does just this a while ago. 安德斯·奥尔森(Anders Ohlsson)组合了一个VCL扫描仪应用程序 ,该应用程序不久前就完成了。 The source code is also available. 源代码也可用。

Up until Delphi 2006, you could use the vcltest3.dll for this. 在Delphi 2006之前,您可以使用vcltest3.dll But now you have to go the way Rob Kennedy proposes. 但是,现在您必须按照罗伯·肯尼迪的建议行事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM