设置EXE VersionInfo [英] Set EXE VersionInfo

查看:403
本文介绍了设置EXE VersionInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 VerQueryValue 。是否有可以注册(建立或更改)此类信息的逆函数(WinApi或Delphi)?
在这里,例如,有一个能够这样做的程序。它可以如何工作( http://www.angusj.com/resourcehacker )?

The information on the version Exe-file I receive by means of VerQueryValue. Is there an inverse function (WinApi or Delphi) which can register (establish or change) such information? Here, for example, there is a program which is able to do so. How may it work (http://www.angusj.com/resourcehacker)?

推荐答案

版本信息通过资源存储;编辑您只需编辑该资源。这是一个单位,我发现可以克隆现有的文件版本信息并将其附加到另一个文件。从这个代码开始,这是很容易的(它是由我的一个朋友编码的,可以公开):

The version information is stored via resources; to edit that you simply need to edit that resource. Here is a unit I found that can clone an existing file version information and attach it to another file. It's very easy to do what you want starting from this code (it's coded by a friend of mine and is available public):

unit cloneinfo;

interface

uses Windows, SysUtils;

type
 LANGANDCODEPAGE = record
  wLanguage: Word;
  wCodePage: Word;
 end;

procedure clone(sFile,output:string);

implementation

procedure clone(sFile,output:string);
var
  dwHandle, cbTranslate: cardinal;
  sizeVers: DWord;
  lpData, langData: Pointer;
  lpTranslate: ^LANGANDCODEPAGE;
  hRes : THandle;
begin
 sizeVers := GetFileVersionInfoSize(PChar(sFile), dwHandle);
 If sizeVers = 0 then
 exit;
 GetMem(lpData, sizeVers);
 try
  ZeroMemory(lpData, sizeVers);
  GetFileVersionInfo (PChar(sFile), 0, sizeVers, lpData);
  If not VerQueryValue (lpData, '\VarFileInfo\Translation', langData, cbTranslate) then
  exit;
  hRes := BeginUpdateResource(pchar(output), FALSE);
  //For i := 0 to (cbTranslate div sizeof(LANGANDCODEPAGE)) do
  //begin
  lpTranslate := Pointer(Integer(langData) + sizeof(LANGANDCODEPAGE));
  UpdateResource(hRes, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), lpTranslate^.wLanguage,lpData, sizeVers);
  //end;
  EndUpdateResource(hRes, FALSE);
 finally
  FreeMem(lpData);
 end;
end;


end.

这篇关于设置EXE VersionInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆