【问题标题】:Using Office Interop Application Object to get the PowerPoint version during installation with Inno Setup使用 Office Interop 应用程序对象在使用 Inno Setup 安装期间获取 PowerPoint 版本
【发布时间】:2023-01-25 05:16:46
【问题描述】:

在使用 Inno Setup 安装程序安装我们的 PowerPoint 加载项期间,我需要通过查询 Application.PowerPoint 对象本身来获取当前使用的 PowerPoint 版本 - 而不是依赖注册表项 which can't be guaranteed to give the correct value

我已经使用以下代码为使用 WIX based on this answer 编写的 MSI 安装程序成功实现了这一点:

Imports Microsoft.Office.Interop.PowerPoint

Public Class Environment

  Public Shared Function GetPowerPointVersion() As String

    Dim CurVer As String
    Dim thisPowerPoint As Object

    thisPowerPoint = New Application()
    CurVer = thisPowerPoint.Version
    thisPowerPoint.Quit()

    Return CurVer

  End Function

End Class

我不完全相信这在所有情况下都有效(可能是偏执狂),所以如果失败,将放入 try/catch 块并使用注册表方法。

我一直无法弄清楚如何使用 Inno Setup 安装程序做类似的事情。有一些使用 DLL 的示例 - https://jrsoftware.org/ishelp/index.php?topic=scriptdll - 但我看不出如何从中创建一个可从 Inno Setup 调用的函数,该函数将返回版本号。

【问题讨论】:

标签: vb.net powerpoint inno-setup office-interop


【解决方案1】:

您可以使用CreateOleObject 调用 PowerPoint 并返回版本:

[Code]
function GetPowerPointVersion(): string;
var
  MyPowerPoint: Variant;
begin
  MyPowerPoint := CreateOleObject('PowerPoint.Application');
  Result := MyPowerPoint.Version;
  MyPowerPoint.Quit;
end;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多