Managing Plugin Modules (Delphi)

Hydra provides several ways to load a plugin module; to load the module you always need a module manager. Depending on used framework, it can be

  • THYSimpleModuleManager - Module manager for console application. Works with plugins via cross-platform interfaces.
  • THYModuleManager - Module manager for VCL hosts. works with plugins via IHYVCL* interfaces. requires runtime packages for using with VCL plugins
  • THYVCLSimpleModuleManager - lightweigh version of module manager for VCL hosts. Works with plugins via crossplatform interfaces.
  • THYFMXModuleManager - Module manager for VCL hosts. works with plugins via IHYFMX* interfaces. requires runtime packages for using with FMX plugins

Most of the methods work in a same way for each these components, so let's review these methods:

General

ModuleManager.LoadModule('MyModule.dll', false);

Two last methods loads modules specified in the ModulesToLoad property of the module manager.

ModuleManager.LoadModules('*.dll', false);

ModuleManager.ModulesToLoad.Add('MyModule.dll');
ModuleManager.LoadModules;
  • AutoLoad property - Module manager can load modules automatically after its creation, to do this you first need to set a list of module file names in the ModulesToLoad property.

Specific

ModuleManager.LoadComModule('{7E47FB9E-8F3C-4F79-AA03-DB5A07033FE3}');
ModuleManager.LoadJavaModule('sample.nonvisual.plugin.jar');
ModuleManager.LoadManagedModule('Net.Plugin2.dll', hcdNewAppDomain);
ModuleManager.LoadManagedModule('Net.Plugin.dll', false);
ModuleManager.LoadSilverlightModule('MySilverlightPlugin.xap');
ModuleManager.LoadUnmanagedCrossPlatformModule('FMXPlugin.dll');
ModuleManager.LoadUnmanagedModule('VCLPlugin.dll');
ModuleManager.LoadVCLModule('VCLPlugin.dll');
ModuleManager.LoadFiremonkeyModule('FMXPlugin.dll');

Unloading Modules

There is no need to manually unload modules since Hydra will do this automatically when the module manager is destroyed, however, module manager provides several methods to preform this task:

Please note that you must release all plugin instances before you unload a module, or you will get an exception.