A package is a specially compiled
library used by applications, the IDE, or both. Packages allow you to rearrange
when code resides without affecting the source code. This is sometimes referred
to as application partitioning.
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 referencing runtime packages in their requires
clauses.
To distinguish them from other
libraries, packages are stored in files:
· On Windows,
package files end with the .bpl (Borland package library) extension.
· On Linux,
packages generally begin with the prefix bpl and have a .so extension.
Ordinarily, packages are loaded
statically when an applications starts. But you can use the LoadPackage
and UnloadPackage routines (in the SysUtils unit) to load
packages dynamically.
Note: When an application utilizes packages, the name of each packaged
unit still must appear in the uses clause of any source file that
references it.
Package declarations
and source files
Libraries and packages: Overview
Unit references and the uses clause
包作为特殊编译的库,用于应用程序和IDE(集成开发环境)。包允许在不影响源代码驻留的条件下重新整理程序。这一特性有时用于应用程序分发(application partitioning)。
运行时包(Runtime packages)在用户运行应用程序时提供功能性支持。设计时包(Design-time packages)用于在IDE中安装定制组件并为这些定制组件创建特别的属性编辑器。一个单独的包既可以作为运行时包,也可以作为设计时包。设计时包通常通过其requires子句中对运行时包的引用来工作。
下列方法可区存储在文件中的别库和包:
· 在Windows中,包的文件名以.bpl(Borland package library)作为扩展文件名。
· 在Linux中,包文件一般以bpl作为前缀并且以.so作为扩展文件名。
通常,包在应用程序启动时被静态加载。但可以用SysUtils单元中的LoadPackage和UnloadPackage例程来实现包的动态加载和卸载。
注意:当一个应用程序利用包时,封装在包中的每个单元,其单元名仍必须出现在相关源文件的uses子句中。