RAD Studio |  |

Loading Packages with the LoadPackage Function
See Also
Collapse All

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.

Copy Code

    with OpenDialog1 do
      if Execute then
        with PackageList.Items do
          AddObject(FileName, Pointer(LoadPackage(FileName)));

Copy Code

    if (OpenDialog1->Execute())
      PackageList->Items->AddObject(OpenDialog1->FileName, (TObject *)LoadPackage(OpenDialog1->FileName));

To unload a package dynamically, call UnloadPackage. Be careful to destroy any instances of classes defined in the package and to unregister classes that were registered by it.

See Also

Working with Packages and Components: Overview

Runtime Packages

Deploying Packages

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