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.
with OpenDialog1 do if Execute then with PackageList.Items do AddObject(FileName, Pointer(LoadPackage(FileName)));
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.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|