Files
DP44/docs/ai/DataPRO/Modules/InstallerCustomActions/Common.md
2026-04-17 14:55:32 -04:00

3.1 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/InstallerCustomActions/Common/PreviousInstall.cs
2026-04-17T16:11:25.802939+00:00 zai-org/GLM-5-FP8 1 d28200fca61fff55

Common

Purpose: This module provides utility logic for Windows Installer custom actions. Its primary role is to interact with the Windows Registry to detect previous installations of the software. It identifies the most recent version installed (that is older than the currently installing version) and determines its installation path, facilitating upgrade or migration scenarios.

Public Interface:

  • PreviousInstall (Static Class)
    • string GetMostRecentlyInstalledSubKeyName(Version installingVersion, out string mostRecentlyInstalledLowerVersion): Scans the registry (specifically HKLM\Software\...Products) for installed versions of "DataPRO". Returns the subkey name of the most recent version found that is less than installingVersion. The out parameter returns the version string.
    • string GetMostRecentlyInstalledPath(string mostRecentlyInstalledSubKeyName): Given a product subkey name, searches the registry ("Products" and "Components" keys) to find the installation directory path.
    • bool IsGreaterThan(this Version leftString, Version rightString) (Extension Method): Returns true if leftString > rightString.
    • bool IsLessThan(this Version leftString, Version rightString) (Extension Method): Returns true if leftString < rightString.

Invariants:

  • Registry paths are read from Settings.Default (e.g., RegistrySoftwareInstalledProducts, RegistryDisplayName).
  • The module specifically targets the RegistryHive.LocalMachine with RegistryView.Registry64.
  • GetMostRecentlyInstalledSubKeyName only considers versions strictly less than installingVersion.
  • GetMostRecentlyInstalledPath modifies the path string if it contains "DTSSuite", appending the DataPRO folder name.

Dependencies:

  • Depends on:
    • System
    • Microsoft.Win32
    • Common.Properties (for Settings.Default)
    • System.Diagnostics (for EventLog)
  • Depended on by: Installer custom actions (implied by module path).

Gotchas:

  • Hardcoded Event Log Source: The method GetMostRecentlyInstalledPath creates an EventLog with Source = "DataPROInstaller". If this source does not exist on the target machine, writing to the log may throw a security exception if the installer does not have sufficient privileges or if the source isn't registered beforehand.
  • Magic Strings/Values: The code checks for val == "-1" to indicate missing registry values, which relies on the specific implementation of GetValue(...).ToString().
  • Path Logic: The logic appending Settings.Default.RegistryDataPRO + "\\" when DTSSuite is detected assumes a specific directory structure that may break if the suite installation layout changes.
  • Extension Method Scope: The IsGreaterThan and IsLessThan extension methods are defined in a static class but are effectively utility methods for Version objects used within this class.