views:

122

answers:

4

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).

A: 

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

Tobiasopdenbrouw
I don't know, really (never used dcluser.dpk before). Edited the question to make the problem clearer.
Martijn
+1  A: 

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

Serg
+3  A: 

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.

Marjan Venema
Thanks for the detailed description: my point is that somehow Delphi knows to find the source code (you can access is via the uses clause in the IDE), which is what I'm trying to achieve. Updating the library path is of course a separate action (I don't know how to do this), but it does achieve what I'm aftger.
Martijn
@Martijn: When you ctrl-click a unit in the uses (or right click and select "open file at cursor") Delphi knows where to find the source **because** of what is in the library path! Or in the "browsing" path. Delphi has no other way of knowing where the units are. In fact, when you empty both those paths, Delphi won't find any of the sources of any of your components.
Marjan Venema
Once again: thanks for the info!
Martijn
A: 

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.

DwrCymru