查看bpl 引用的dll
When we write and compile a Delphi application, we typically generate an executable file - a standalone Windows application. Unlike Visual Basic, for example, Delphi produces applications wrapped in compact exe files, with no need for bulky runtime libraries (DLL's).
当我们编写和编译Delphi应用程序时,通常会生成一个可执行文件-一个独立的Windows应用程序。 例如,与Visual Basic不同, Delphi可以将应用程序封装在紧凑的exe文件中,而无需庞大的运行时库(DLL)。
Try this: start Delphi and compile that default project with one blank form, this will produce an executable file of about 385 KB (Delphi 2006). Now go to Project - Options - Packages and check the 'Build with runtime packages' check box. Compile and run. Voila, the exe size is now around 18 KB.
尝试以下操作:启动Delphi并使用一个空白表格编译该默认项目,这将产生大约385 KB的可执行文件(Delphi 2006)。 现在转到项目-选项-包,然后选中“使用运行时包构建”复选框。 编译并运行。 瞧,exe的大小现在约为18 KB。
By default the 'Build with runtime packages' is unchecked and every time we make a Delphi application, the compiler links all the code your application requires to run directly into your application's executable file. Your application is a standalone program and doesn't require any supporting files (like DLLs) - that's why Delphi exe's are so big.
默认情况下,“使用运行时程序包构建”是未选中的,并且每次我们制作Delphi应用程序时,编译器会将应用程序需要直接运行的所有代码直接链接到应用程序的可执行文件中 。 您的应用程序是一个独立程序,不需要任何支持文件(例如DLL)-这就是Delphi exe这么大的原因。
One way of creating smaller Delphi programs is to take advantage of 'Borland package libraries' or BPL's in short.
创建较小的Delphi程序的一种方法是利用“ Borland软件包库”或简称BPL。
什么是包裹? ( What's a Package? )
special dynamic-link library used by Delphi applications Delphi应用程序使用的特殊动态链接库Packages enable us to place portions of our application into separate modules that can be shared across multiple applications. Packages, also, provide a means of installing (custom) components into Delphi's VCL pallete.
包使我们能够将应用程序的各个部分放置到可以在多个应用程序之间共享的单独模块中。 软件包还提供了一种将(自定义)组件安装到Delphi的VCL托盘中的方法。
Therefore, basically two types of packages can be made by Delphi:
因此,Delphi基本上可以制作两种类型的软件包:
- Run-time packages - provide functionality when a user runs an application - they operate much like standard DLLs. 运行时程序包-在用户运行应用程序时提供功能-它们的运行方式与标准DLL非常相似。
Design-time packages - used to install components in the Delphi IDE and to create special property editors for custom components.
设计时软件包-用于在Delphi IDE中安装组件并为自定义组件创建特殊的属性编辑器。
From this point this article will deal with run-time packages and how they can help Delphi programmer.
从这一点出发,本文将介绍运行时软件包以及它们如何帮助Delphi程序员。
One wrong mit: you are not required to be a Delphi component developer to take advantage of packages. Beginner Delphi programmers should try working with packages - they'll get better understanding of how packages and Delphi work.
一个错误的秘诀 :您无需成为Delphi组件开发人员即可利用软件包。 初学者的Delphi程序员应该尝试使用软件包-他们将更好地了解软件包和Delphi的工作方式。
何时以及何时不使用软件包 ( When and when Not ot Use Packages )
DLLs are most commonly used as collections of procedures and functions that other programs can call. Besides writing DLLs with custom routines, we can place a complete Delphi form in a DLL (for example an AboutBox form). Another common technique is to store nothing but resources in DLLs. More information on how Delphi operates with DLLs find in this article: DLLs and Delphi.
DLL最常用作其他程序可以调用的过程和函数的集合。 除了使用自定义例程编写DLL外,我们还可以在DLL中放置完整的Delphi表单(例如AboutBox表单)。 另一种常用的技术是在DLL中只存储资源。 有关Delphi如何使用DLL的更多信息,请参见本文: DLL和Delphi 。
Before going on to comparison between DLLs and BPLs we have to understand two ways of linking code in an executable: static and dynamic linking.
在继续比较DLL和BPL之间之前,我们必须了解两种在可执行文件中链接代码的方式:静态链接和动态链接。
Static linking means that when a Delphi project is compiled, all the code that your application requires is directly linked into your application's executable file. The resulting exe file contains all the code from all the units that are involved in a project. Too much code, you might say. By default, uses clause for a new form unit list more than 5 units (Windows, Messages, SysUtils, ...). However, the Delphi linker is smart enough to link only the minimum of code in the units actually used by a project. With static linking our application is a standalone program and doesn't require any supporting packages or DLLs (forget BDE and ActiveX components for now). In Delphi, static linking is the default.
静态链接意味着编译Delphi项目时,应用程序所需的所有代码都直接链接到应用程序的可执行文件中。 生成的exe文件包含项目中涉及的所有单元的所有代码。 您可能会说,代码太多。 默认情况下,uses子句用于一个新的表单单位列表,该列表超过5个单位(Windows,Messages,SysUtils等)。 但是,Delphi链接器非常聪明,仅可以链接项目实际使用的单位中的最少代码。 通过静态链接,我们的应用程序是一个独立程序,不需要任何支持程序包或DLL(现在不再需要BDE和ActiveX组件)。 在Delphi中,默认为静态链接 。
Dynamic linking is like working with standard DLLs. That is, dynamic linking provides functionality to multiple applications without binding the code directly to each application - any required packages are loaded at runtime. The greatest thing about dynamic linking is that loading of packages by your application is automatic. You don't have to write code to load the packages neither you have to change your code.
动态链接就像使用标准DLL。 也就是说,动态链接可为多个应用程序提供功能,而无需将代码直接绑定到每个应用程序-任何必需的程序包都会在运行时加载。 动态链接的最大优点是,应用程序自动加载程序包。 您无需编写代码来加载软件包,也无需更改代码。
Simply check the 'Build with runtime packages' check box found on the Project | Options dialog box. The next time you build your application, your project's code will be linked dynamically to runtime packages rather than having units linked statically into your executable file.
只需在Project | Project(项目)上选中“使用运行时软件包生成”复选框即可。 选项对话框。 下次构建应用程序时,项目代码将动态链接到运行时包,而不是将单元静态链接到可执行文件中。
查看bpl 引用的dll