设置 EXE 版本信息

发布于 2024-12-10 02:19:52 字数 339 浏览 0 评论 0原文

有关我通过 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)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请帮我爱他 2024-12-17 02:19:52

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

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.

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文