2
votes

I'm writing a package in Delphi 2007 containing a component and several classes. I want to "install" the classes as well as the components.

To be more precise: when a component is installed, the unit is somehow registered such that it is not necessary to add its path to the search path in the project. I would also like to do this with a few extra units that do not contain components: if I can somehow register the root of the package, I'm done. Is this possible?

EDIT: In one sentence the objective is: If somebody installs my package, it is not necessary to add the path to the units in the package is added to the library path of Delphi (so this does not have to be done by hand).

4
I don't like component libraries messing with my library path without asking me. As a matter of fact, my environment options library path is empty. Not even the standard bds library paths are in there.Marjan Venema
@Marjan Venema: good point. I'll keep that in mind!Martijn

4 Answers

3
votes

To be more precise: when a component is installed, the unit is somehow registered such that it is not necessary to add its path to the search path in the project.

The unit is not registered anywhere. When a component is installed, the bpl package in which it resides is added to the known packages list when the IDE starts, it will call all the Register procedures (note the capital R) in each of the known packages. These Register procedures contain code to get the components registered on the tool palette.

If you set up the component package(s) correctly, the IDE will also know which units to add to a form's uses clause when you drop a component on a form.

The library path in the environment options is not part of all this. If it is being amended by installing a component, that is being done by the component's installation program as a separate action in addition to adding the component's bpl to the IDE.

1
votes

When I create a simple component package, I usually set "Unit Output Directory" package option to $(BDSCOMMONDIR)\Dcp instead of adding paths to Library paths - it is more simple. You can download my ksTools package as an example - it is pure source code package with detailed installation instructions

0
votes

Would adding it to dcluser.dpk and compiling that be enough for you?

0
votes

The IDE will also need to know where any DCU's associated with the package are stored. This wil mean having to add the actual path (where the DCU's are located) to the IDE's "Library Path", or storing them in a location that is already registered as a Library Path.