【问题标题】:Get version number of compact framework exe from Delphi PC application从 Delphi PC 应用程序获取紧凑框架 exe 的版本号
【发布时间】:2014-06-10 04:49:15
【问题描述】:

我有一个为 Compact Framework 编译的应用程序,我需要找到使用 Delphi 2006 的版本号。我正在使用下面的代码。

function VersionNumber(ExeFile: string): string;
var
  Size: Longint;
  Dummy: Cardinal;
  Buffer: Pointer;
  FileInfo: Pointer;
begin
  Size := GetFileVersionInfoSize(PChar(ExeFile), Dummy);
  GetMem(Buffer, Size);
  if (GetFileVersionInfo(PChar(ExeFile), Dummy, Size, Buffer)) then begin
   //VerQueryValue(Buffer, '\\', FileInfo, Dummy);
    //with PVSFixedFileInfo(FileInfo)^ do
      //Result := IntToStr(dwFileVersionMS div $10000) + '.' +
      //  IntToStr(dwFileVersionMS mod $10000) + '.' +
      //  IntToStr(dwFileVersionLS div $10000) + ' (' +
      //  IntToStr(dwFileVersionLS mod $10000) + ')';
  end
  else begin
    Result := 'No version info available.';
  end;
  FreeMem(Buffer, Size);
end;

如果我使用 Windows 7 查看文件详细信息,我也看不到版本号,因此我无法从 Delphi 获取它也就不足为奇了。

如果有人知道获取版本号的方法,将不胜感激。

更新

这段代码是十多年前由一位前工作人员编写的。到目前为止,它运行良好,但从未在为 Compact Framework 编译的可执行文件上进行过尝试。

GetFileVersionInfo 函数返回 false,因此我收到“没有可用的版本信息”。结果。

【问题讨论】:

  • 你的代码输出什么
  • 寻找不存在的资源是没有意义的。我认为你应该删除所有不必要的代码并向我们展示你在寻找什么。如果它不是版本资源,它是什么?一些 .net 元数据。但是什么?
  • 这可能很有用:oncoding.blogspot.co.uk/2012/04/… 从本质上讲,我的信念是,在你继续前进之前,你需要弄清楚你在寻找什么。

标签: delphi compact-framework delphi-2006


【解决方案1】:

CF 不会将 C/C++ FileVersionInfo 放入 exe 或 DLL 文件中。 AssemblyInfo 与您在代码示例中寻找的 FileVersionInfo 资源不同。

ctacke 在http://blog.opennetcf.com/2014/01/03/howto-add-the-win32-file-version-to-your-net-compact-framework-assemblies/ 有一个有用的帖子,可以通过Version information missing from .NET assembly (Compact Framework 3.5/VS2008) 找到,graymatter 已经发布了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多