Plug-ins Explained - Building your own packages
(Page 2 of 4 )
Creating a package is surprisingly easy. Go to File|New|Other and select Package from the object repository:

Once you've clicked on the packages icon, you should see the following screen:

The package editor enables you to add and remove units to and from the package. It is always good to save the package in its own folder, to keep the generated files together. Before you compile a package, make sure that the output directory points to the same directory where you want to save the package. You do this by opening up the Project Options dialog box, by clicking on the options button, selecting the "Directory/Conditional" ta,b and then entering the directory location. When you compile the package it will create DCP, DCU and BPL files, which you want to have in the same location, especially if you are going to use them to create plug-ins.

As you can see from the package editor, the editor has two lists:
- Contain: The "contains" clause is responsible for listing all the units that the package will contain. You add units to the package by clicking on the "Add" button.
- Requires: In Delphi 7, the required run-time package is VCL70.dcp. This is required in case your units use anything from the VCL. The package editor will automatically add the required VCL according to what is needed by the units listed in the "Contain" clause.
To avoid using the VCL twice in your application, make sure that you built your application using the VCL run-time packages.
When you create, save or compile a package, a couple of files are generated. So let' s look at these files:
- .DPK - Contains the package source code.
- .DCU - Binary image for a unit file contained in the package. One DCU file is created for each unit file.
- DCP - Links with the run-time package.
- .BPL - The file that you will need to deploy with your application.
To finish building a package, simply compile the package and a .bpl will be created and stored in the directory that you specified. If you did not specify an output directory, the .bpl file will be put in the DelphinProjectsBPL directory.
Next: Linking your package >>
More Delphi-Kylix Articles
More By Leidago