RAD Studio |  |

Loading Packages in an Application
See Also
Collapse All

You can dynamically load packages by either:

- Choosing Project Options dialog box in the IDE; or
- Using the LoadPackage function.

To load packages using the >Project>Options dialog box

1. Load or create a project in the IDE.
2. Choose ProjectOptions.
3. Choose the Packages tab.
4. Select the Build with Runtime Packages check box, and enter one or more package names in the edit box underneath. Each package is loaded implicitly only when it is needed (that is, when you refer to an object defined in one of the units in that package). (Runtime packages associated with installed design-time packages are already listed in the edit box.)
5. To add a package to an existing list, click the Add button and enter the name of the new package in the Add Runtime Package dialog. To browse from a list of available packages, click the Add button, then click the Browse button next to the Package Name edit box in the Add Runtime Package dialog. If you edit the Search Path edit box in the Add Runtime Package dialog, you can change the global Library Path. You do not need to include file extensions with package names (or the version number representing the Delphi release); that is, vcl90.bpl in a VCL application is written as vcl. If you type directly into the Runtime Package edit box, be sure to separate multiple names with semicolons. For example:

Copy Code

    rtl;vcl;vcldb;vclado;

    vclbde;

Packages listed in the Runtime Packages edit box are automatically linked to your application when you compile. Duplicate package names are ignored, and if the Build with runtime packages check box is unchecked, the application is compiled without packages. Runtime packages are selected for the current project only. To make the current choices into automatic defaults for new projects, select the Defaults check box at the bottom of the dialog.

Note: When you create an application with packages, you must include the names of the original Delphi units in the uses clause of your source files. For example, the source file for your main form might begin like this:
Copy Code

    unit MainForm;
    interface
    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs;

Copy Code

    #include "vcldb.h"

The units referenced in this VCL example are contained in the vcl and rtl packages. Nonetheless, you must keep these references in the uses clause, even if you use vcl and rtl in your application, or you will get compiler errors. In generated source files, the Form Designer adds these units to the uses clause automatically.

See Also

Deciding Which Runtime Packages to Use

Working with Packages and Components: Overview

Deploying Packages

Loading Packages with the LoadPackage Function

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!