如果设置中的字体版本高于安装的版本,请使用 Inno Setup 安装字体

Install font with Inno Setup if the version of the font in the setup is higher than one installed

我有一个随 Inno Setup 安装的自定义字体,我想仅在我的设置中的字体升级后才覆盖现有字体。

为了做到这一点,我试图从我的字体文件中获取版本,但是 GetVersionNumbersString 在函数中或 GetFileVersionString 在 Inno Setup 预处理器中。据我了解,这些功能仅适用于 exe 或 dll,但我可能错了。

任何帮助我实现这一目标的线索都将不胜感激。

谢谢,

奥利维尔

您可以使用以下代码提取TTF文件(可能是任何文件)版本:

function GetShellItemVersion(Path: string): string;
var
  Shell, Folder, Item, Version: Variant;
  FolderPath: string;
begin
  Shell := CreateOleObject('Shell.Application');
  FolderPath := ExtractFilePath(Path);
  Folder := Shell.NameSpace(FolderPath);
  if VarIsClear(Folder) then
  begin
    Log(Format('Error reading folder "%s"', [FolderPath]));
  end
    else
  begin
    Item := Folder.ParseName(ExtractFileName(Path));
    if VarIsClear(Item) then
    begin
      Log(Format('Error accessing "%s"', [Path]));
    end
      else
    begin
      Version := Folder.GetDetailsOf(Item, 166);
      if VarIsClear(Version) then
      begin
        Log(Format('Error reading version of "%s"', [Path]));
      end
        else
      begin
        Result := Version;
        Log(Format('Version of "%s" is "%s"', [Path, Result]));
      end;
    end;
  end;
end;

基于.