Set EXE VersionInfo

走远了吗. 提交于 2019-12-02 19:48:09
opc0de

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!