Jump to content
limelect

Create PersistentClass from component name

Recommended Posts

Another one on an expert

I have this part of an expert program list of component names

 

var
  PackageServices: IOTAPackageServices;
  PackageCounter: Integer;
  ComponentCounter: Integer;
  InstalledComponentName: string;
  

  PackageServices := BorlandIDEServices as IOTAPackageServices;
  
   for PackageCounter := 0 to PackageServices.PackageCount - 1 do
    begin
      for ComponentCounter := 0 to
        PackageServices.GetComponentCount(PackageCounter) - 1 do
      begin
        InstalledComponentName := PackageServices.ComponentNames[PackageCounter,
        ComponentCounter]; <<<< here i get component name as a string

 

On another program, that I want to merge the two.

 

type 
  TClassArray = array[1..{179} 169] of TPersistentClass;

  ClassArray: TClassArray = (
    TBitmap, TGraphic, TOutlineNode, TGraphicsObject,
 

Now to my question  Is it possible to get from the above the component as 

TPersistentClass; which mean

 

var

x:TPersistentClass;


x:=PackageServices.ComponentNames[PackageCounter,
        ComponentCounter]; <<<<< ???????

obviously one is string one is TPersistentClass; 

How to? Or am I wrong with my idea?

 

Which mean getting all components as TPersistentClass, and not as strings

 

 

 

 

 

 

 

 

 

Edited by limelect

Share this post


Link to post

Although I am not aware of a way to get this directly, there actually is a function to get the TPersistentClass from the class name: GetClass

Share this post


Link to post

@Uwe Raabe You are correct but information of components are in package > PackageServices

PackageServices := BorlandIDEServices as IOTAPackageServices;

Unless there is another way to get the component >TPersistentClass; in the package

Share this post


Link to post

@Uwe Raabe      It mite work thanks  xx:TPersistentClass;

  xx:=GetClass(PackageServices.ComponentNames[PackageCounter,
        ComponentCounter]);

Share this post


Link to post

I guess the real reason, why Delphi represents components in packages as string names (as opposed to direct TClass references) is because a package can stay in non-loaded state. Look at IOTAPackageInfo.Loaded property.

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

×