Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "scan" the full list of currently-installed VCL components

I still haven't found a truly satisfactory answer to this question, and am now considering rolling my own. I have ModelMaker and GExperts, and neither seems to load the comprehensive class-hierarchy I am looking for. As well, I don't think the folks at DevExpress will fork over the CDK code which compiles a full class list to inherit from... ;-)

SO...

If ALL I want to do is build a self-referencing table of all registered component classes (or even all classes including non-components, if that's just as easy/possible), what would be the best way to go about doing that?

Note: I don't really need property / method details; JUST a complete list of class names (and parent names) I can store to a table and put in a treeview. Anything beyond that, though, is more than welcome as bonus info. :-)


Update later:

One answer that shows up in my "recent" section on SO, but not here on the question (maybe they erased it?), was this:

"u may want to take a look on code of Component Search, it may help you to enumrate all components installed."

Is that code available? Is so, where is it hiding? Would be interesting to study.

like image 450
Jamo Avatar asked Apr 18 '09 10:04

Jamo


Video Answer


1 Answers

Unfortunately, the code implementing the RegisterClass mechanism is hidden in Classes implementation section.

If you need this for getting the list of components installed in the IDE, you can write a design package, install it into the IDE and use IOTAPackageServices in ToolsAPI unit. This will give you the list of installed packages and their components.

Note: You'll have to add designide.dcp to your 'requires' clause to be able to use Delphi's internal units like ToolsAPI.

A bit more work but a more generic way would be to enumerate all loaded modules. You can call GetPackageInfo (SysUtils) on a package module to enumerate contained unit names and required packages. However this will not give you a list of classes contained in the package.

You could enumerate the package's list of exported functions (e.g. with TJclPeImage in the JCL) and search for those named like this:

@<unit_name>@<class_name>@

for example: '@System@TObject@'.

By calling GetProcAddress with the function name you get the TClass reference. From there you can walk the hierarchy using ClassParent. This way you can enumerate all classes in all packages loaded in a process running a Delphi executable compiled with runtime packages (Delphi IDE, too).

like image 70
Ondrej Kelle Avatar answered Oct 05 '22 18:10

Ondrej Kelle