Install EXE VersionInfo

Information about the version of the Exe file that I get with VerQueryValue . Is there a reverse function (WinApi or Delphi) that can register (install or modify) such information? Here, for example, there is a program that is able to do this. How does it work ( http://www.angusj.com/resourcehacker )?

+6
source share
1 answer

Version information is stored through resources; for editing, you just need to edit this resource. Here is the unit I discovered that can clone existing file version information and attach it to another file. It is very easy to do what you want, starting with this code (it is encoded by my friend and available to the 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. 
+12
source

Source: https://habr.com/ru/post/899477/


All Articles