Jump to content
Bill Meyer

Is there a package to get a list of all installed components?

Recommended Posts

In the course of some project analysis, it has become apparent that we would benefit from exporting a list of all installed components in Delphi. I have found articles discussing how to obtain the list using the ToolsAPI, but that would mean building a package for a wizard, which is more of a side project than I was seeking.

 

If anyone knows of an existing wizard which would provide the functionality, I would appreciate a lead.

 

Bill

Share this post


Link to post
uses ToolsApi;

{....}

var
  a, i: Integer;
begin
  with (BorlandIDEServices as IOTAPackageServices) do
  begin
    for a := 0 to GetPackageCount - 1 do
    begin
      for i := 0 to GetComponentCount(a) - 1 do
      begin
        {get each component name with GetComponentName(a, i);}
        // DoSomething   
      end;
    end;
  end;
end;

Something like that?

Share this post


Link to post

You can also search the registry. The Package Cache key (like HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Package Cache) contains all installed packages with all its components.

Share this post


Link to post
1 hour ago, Uwe Raabe said:

You can also search the registry. The Package Cache key (like HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Package Cache) contains all installed packages with all its components.

I will give that a try, Uwe, thanks. 

Share this post


Link to post
1 hour ago, haentschman said:

...no! Why whith "WITH"! :classic_unsure:

Okay.

uses TypInfo, ToolIntf, Exptintf;

...

procedure GetComponentNames(lst: TStrings);
var
  i, k: Integer;
  CRef: TClass;
  strName: ShortString;
begin
  lst.Clear;
  for i := 0 to ToolServices.GetModuleCount-1 do
  begin
    for k := 0 to ToolServices.GetComponentCount(i)-1 do
      begin
       CRef := TClass(GetClass(ToolServices.GetComponentName(i, k)));
       while CRef <> nil do
       begin
         strName := CRef.ClassName;
         if lst.IndexOf(strName) = -1 then
           lst.Add(strName);
         if str <> 'TComponent' then
          CRef := CRef.ClassParent
         else
           CRef := nil;
       end;
      end;
  end;    
end;

 

Share this post


Link to post
On 11/16/2018 at 4:16 PM, Uwe Raabe said:

You can also search the registry. The Package Cache key (like HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Package Cache) contains all installed packages with all its components.

As it happens, I need to run in XE7, where the key is this: HKEY_CURRENT_USER\Software\Embarcadero\BDS\15.0\ToolForm\Mapping. I also have an interest, though no absolute need, to run this in D2007, but I find no entry in the registry for such information. Has anyone committed a web page on the variations of such content in different versions?

Share this post


Link to post
3 hours ago, KodeZwerg said:

Does the code not work?

Which code? You posted code for use in a package. I am now scanning the registry, and collecting from there with my own code, which works fine, though there are a few idiosyncrasies in the lists there.

 

The  point of my last post, though, was that although the registry scan is convenient, it is specific right now to XE7. And given the minor irregularities I have found in the entries there, it seems reasonable to anticipate irregularities in other versions, whether the same or different to these. In D2007, however, I find no evidence of installed components in the registry, so in the end, the ToolsAPI may be the only reliable approach.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×