Plugin Lifecycle¶
sequenceDiagram
participant Host as Host
participant P as Plugin
Note over Host: Application startup: read [Plugin] from the INI, LoadLibrary, SetHostCallback
Host->>P: GetInfo({})
P-->>Host: {name, version, apiVersion, capabilities, menus, hasSettings}
Note over Host: Refuse if apiVersion is higher than supported
Host->>P: Initialize({hostVersion, configPath, hostDataPath, mainWindowHandle, windowsUser, windowsDomain})
P-->>Host: {} (OK)
Note over Host: Build menus from GetInfo.menus
Host->>P: GetMenuItemState({menuItemIds, context})
Note over Host: ... user works ...
Note over Host: Application shutdown
Host->>P: Finalize({})
P-->>Host: {} (OK)
Note over Host: FreeLibrary
The plugin is loaded once per process. If Enabled=0 in the host INI, or the [Plugin] section is missing, nothing is loaded and no message is shown. See HydroSym Build & Deploy or HydroMan Build & Deploy for the INI keys.
Step 1: GetInfo¶
Called immediately after the DLL is loaded. The host uses the response to:
- Check
apiVersion(see Versioning). - Record
capabilities: only listed optional methods are called (see Architecture). - Build menus from
menus. - Add a Settings item if
hasSettingsis true.
Keep GetInfo fast and side-effect free. Do not open connections there. GetInfo must return OK; an error or null fails the load.
Step 2: Initialize¶
Called once, after GetInfo. Field schemas: HydroSym Initialize ยท HydroMan Initialize.
Read your config from ConfigPath and connect to external systems here. The host callback is registered before GetInfo, so Host.* already works during Initialize. No document is open yet, so project-scoped calls such as Host.GetCurrentProject fail with NO_PROJECT_OPEN.
If Initialize throws, the host shows a warning dialog ("Plugin failed to load ..."), skips Finalize, and unloads the DLL. The application continues without the plugin.
Step 3: Normal operation¶
The host calls your plugin from the UI thread in response to user actions: menu clicks, menu popups, file open, and file close. Optional methods run only when advertised.
- HydroSym: Call Sequences, including the CLI PDF path.
- HydroMan: Call Sequences. HydroMan does not call plugin
GetProjectVariables; on confirmed close,SetProjectVariablesarrives with an emptyvariablesmap.
Step 4: Finalize¶
Called once, when the application shuts down. Close connections and release resources. Host.* remains available until Finalize returns. Errors are logged and shutdown continues.
There is no plugin reload. Changing the DLL or INI takes effect at the next start of the host.
Finalize on crash
If the host crashes, Finalize is not called. Design resources such as locks and temp files to be recoverable on the next start.