Name |
Description |
You can also load a package at runtime by calling the LoadPackage function. LoadPackage loads the package specified by its name parameter, checks for duplicate units, and calls the initialization blocks of all units contained in the package. For example, the following code could be executed when a file is chosen in a file-selection dialog. | |
A package is a special dynamic-link library used by applications, the IDE, or both. Runtime packages provide functionality when a user runs an application. Design-time packages are used to install components in the IDE and to create special property editors for custom components. A single package can function at both design time and runtime, and design-time packages frequently work by calling runtime packages. To distinguish them from other DLLs, package libraries are stored in files that end with the .bpl (Borland package library) extension. Like other runtime libraries, packages contain code that can be shared among applications. For... more | |
You can compile a package from the IDE or from the command line. | |
Creating a package involves specifying:
| |
Refer to Understanding the structure of a package for more information about the steps outlined here. | |
A custom package is either a .bpl you code and compile yourself or an existing package from a third-party vendor. To use a custom runtime package with an application, choose ProjectOptions and add the name of the package to the Runtime Packages edit box on the Packages page. For example, suppose you have a statistical package called stats.bpl. To use it in an application, the line you enter in the Runtime Packages edit box might look like this: | |
Several runtime packages, including rtl and vcl (VCL application) , supply basic language and component support. The vcl (VCL) package contains the most commonly used components; the rtl package includes all the non-component system functions and Windows interface elements. It does not include database or other special components, which are available in separate packages. To create a client/server database application that uses packages, you need several runtime packages, including vcl, vcldb, rtl, and dbrtl (VCL) . If you want to use visual components in your application, you also need vclx (VCL) . To use these packages, choose ProjectOptions,... more | |
You deploy packages much like you deploy other applications. The files you distribute with a deployed package may vary. The bpl and any packages or dlls required by the bpl must be distributed. Files deployed with a package | |
Design-time packages are used to install components on the IDE's Tool palette and to create special property editors for custom components. Which ones are installed depends on which edition of Delphi you are using and whether or not you have customized it. You can view a list of what packages are installed on your system by choosing ComponentInstall Packages.... The design-time packages work by calling runtime packages, which they reference in their Requires clause. For example, dclstd references vcl. The dclstd itself contains additional functionality that makes many of the standard components available on the Tool palette... more | |
| |
Package source files, like project files, are generated by Delphi from information you supply. Like project files, they can also be edited manually. A package source file should be saved with the .dpk (Delphi package) extension to avoid confusion with other files containing Del source code. | |
All components are installed in the IDE as packages. If you've written your own components, create and compile a package that contains them. Your component source code must follow the model described in Overview of component creation. | |
Package collections (.dpc files) offer a convenient way to distribute packages to other developers. Each package collection contains one or more packages, including bpls and any additional files you want to distribute with them. When a package collection is selected for IDE installation, its constituent files are automatically extracted from their .pce container; the Installation dialog box offers a choice of installing all packages in the collection or installing packages selectively. | |
To create a package, you compile a source file that has a .dpk extension. The base name of the .dpk file becomes the base name of the files generated by the compiler. For example, if you compile a package source file called traypak.dpk, the compiler creates a package called traypak.bpl. | |
Create a package when you want to make a custom component that's available through the IDE. Create a standard DLL when you want to build a library that can be called from any application, regardless of the development tool used to build the application. The following table lists the file types associated with packages: Package files | |
The following table lists package-specific compiler directives that you can insert into your source code. Package-specific compiler directives | |
Runtime packages are deployed with your applications. They provide functionality when a user runs the application. To run an application that uses packages, a computer must have both the application's executable file and all the packages (.bpl files) that the application uses. The .bpl files must be on the system path for an application to use them. When you deploy an application, you must make sure that users have correct versions of any required .bpls. | |
Packages include the following parts:
| |
You can dynamically load packages by either:
| |
When you compile from the command line, you can use the package-specific switches listed in the following table. Package-specific command-line compiler switches | |
The $WEAKPACKAGEUNIT directive affects the way a .dcu file is stored in a package's .dcp and .bpl files. (For information about files generated by the compiler, see Package files created when compiling.) If {$WEAKPACKAGEUNIT ON} appears in a unit file, the compiler omits the unit from bpls when possible, and creates a non-packaged local copy of the unit when it is required by another application or package. A unit compiled with this directive is said to be weakly packaged. For example, suppose you've created a package called pack1 that contains only one unit, unit1. Suppose unit1 does not... more | |
Design-time packages simplify the tasks of distributing and installing custom components. Runtime packages, which are optional, offer several advantages over conventional programming. By compiling reused code into a runtime library, you can share it among applications. For example, all of your applications—including Delphi itself—can access standard components through packages. Since the applications don't have separate copies of the component library bound into their executables, the executables are much smaller, saving both system resources and hard disk storage. Moreover, packages allow faster compilation because only code unique to the application is compiled with each build. |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|