【问题标题】:Using Delphi to modify the version information of another delphi program使用Delphi修改另一个delphi程序的版本信息
【发布时间】:2010-10-20 06:02:56
【问题描述】:

我想在 Delphi 中创建一个小工具,可以更新另一个 exe 文件中的 Delphi 版本信息。我知道有几个现有的实用程序可以解决这个问题,但我需要完全的程序控制,并且不希望对命令行等进行炮击。

经过网络搜索,我找不到任何在exe中修改版本信息的Delphi源代码示例,谁能提供一些代码或方向?

【问题讨论】:

    标签: delphi version


    【解决方案1】:

    还有 Colin Wilson 的 XN Resource Editor 的源代码可能会有所帮助。

    【讨论】:

    • 引用的链接已失效。
    【解决方案2】:

    我无法给出完整的答案,但我可以帮助您入门。有an article at DelphiDabbler.com 填写如何从文件中获取版本信息。 GetFileVersionInfo 是执行此操作的 Windows API。要设置它,我相信UpdateResource 是您需要使用的 Windows API 函数。 another article at CodeProject 涵盖了这一点,使用 C,但它应该让您对需要做什么有一个坚实的了解。

    祝你好运!

    编辑:我在 Delphi 新闻组上找到了一些代码,可能会给您更多帮助:

    // Credit to Michael Winter for this code!
    Sz := GetLen;
    GetMem(Data, Sz);
    try
      GetData(Data, Sz);
      HFile := BeginUpdateResource(PChar(FileName), false);
      if HFile = 0 then
        RaiseLastWin32Error;
      DoDiscard := true;
      try
        if not UpdateResource(HFile, RT_VERSION, PChar(1), 0, Data, Sz) then
          RaiseLastWin32Error;
        DoDiscard := false;
      finally
        if not EndUpdateResource(HFile, DoDiscard) then
          RaiseLastWin32Error;
      end;
    finally
      FreeMem(Data);
    end;
    

    这只是一个 sn-p,需要您做一些工作,但这是大部分工作!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-22
      • 2010-09-28
      • 2013-07-16
      • 1970-01-01
      • 2011-12-24
      相关资源
      最近更新 更多