如何检测正在运行的 MSI 安装

Mar*_*men 5 c# windows-installer

我正在寻找一种方法来检测 Windows Installer 安装是否已在进行中。到目前为止我发现的是:

  • 检查注册表项:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\InProgress
  • 将 Windows Installer API 函数MSIInstallProduct与虚拟文件结合使用,该文件将返回特定的错误代码。

有人知道更聪明的解决方案吗?