7

我想从我的 Inno Setup 脚本中的 application.exe 中读取这三个值。

[assembly: AssemblyCompany("My Company")]
[assembly: AssemblyProduct("My Great Application")]
[assembly: AssemblyFileVersion("9.3.2")]

有谁知道这可能是如何实现的?

我知道我可以使用GetFileVersion("path/to/greatapp.exe")获得最后一个 ,前两个有类似的东西吗?

4

2 回答 2

11

使用GetStringFileInfo()Inno Setup Preprocessor (ISPP) 提供的函数如下:

  1. GetStringFileInfo("path/to/greatapp.exe", "CompanyName")
  2. GetStringFileInfo("path/to/greatapp.exe", "ProductName")
  3. GetStringFileInfo("path/to/greatapp.exe", "FileVersion")

正如您已经提到的,您可以使用该GetFileVersion()函数而不是上面的#3。

另外,ISPPBuiltins.iss请查看 Inno Setup 安装中包含的脚本文件。它包含一个GetFileCompany()函数来代替上面的#1,你可以用类似的方式实现上面的#2。

于 2012-02-15T22:32:36.020 回答
0

我不知道 Inno Setup,但我猜它支持自定义操作,如其他设置工具(Visual Studio、Wix、InstallShield 或 Wise)。

因此,您将需要创建一个自定义操作来从程序集中读取此信息。在您的自定义操作中,您需要添加以下代码来获取程序集属性:

Assembly assembly  = Assembly.LoadFrom (@"path\to\greatapp.exe");
object[] attributes = assembly.GetCustomAttributes(true);

if (attributes.Length > 0)
{
    foreach (object o in attibutes) 
    {
        //Do Something with the attribute
    }
}
于 2009-09-16T15:03:44.637 回答