delphi - Get FileVersion with Build -


delphixe.

for reception of version of file use function:

function fileversion(afilename: string): string; var   szname: array[0..255] of char;   p: pointer;   value: pointer;   len: uint;   gettranslationstring: string;   ffilename: pchar;   fvalid: boolean;   fsize: dword;   fhandle: dword;   fbuffer: pchar; begin   try     ffilename := strpcopy(stralloc(length(afilename) + 1), afilename);     fvalid := false;     fsize := getfileversioninfosize(ffilename, fhandle);     if fsize > 0     try       getmem(fbuffer, fsize);       fvalid := getfileversioninfo(ffilename, fhandle, fsize, fbuffer);     except       fvalid := false;       raise;     end;     result := '';     if fvalid       verqueryvalue(fbuffer, '\varfileinfo\translation', p, len)     else       p := nil;     if p <> nil       gettranslationstring := inttohex(makelong(hiword(longint(p^)),         loword(longint(p^))), 8);     if fvalid     begin       strpcopy(szname, '\stringfileinfo\' + gettranslationstring +         '\fileversion');       if verqueryvalue(fbuffer, szname, value, len)         result := strpas(pchar(value));     end;       try       if fbuffer <> nil         freemem(fbuffer, fsize);     except     end;     try       strdispose(ffilename);     except     end;   end; end; 

for majority of executed files , libraries returns correct value. @ files version cut off , shown without build. here example file bass.dll (http://us.un4seen.com/files/bass24.zip) in windows explorer in properties of file see version 2.4.7.1, function result='2.4.7' :(

i open file through resourcehacker.exe (http://angusj.com/resourcehacker/), structure versioninfo:

1 versioninfo fileversion 2,4,7,1 productversion 2,4,0,0 fileos 0x4 filetype 0x2 { block "stringfileinfo" {     block "000004b0"     {         value "companyname", "un4seen developments"         value "filedescription", "bass"         value "fileversion", "2.4.7"         value "legalcopyright", "copyright © 1999-2010"     } }  block "varfileinfo" {     value "translation", 0x0000 0x04b0 } } 

question: how receive 2.4.7.1, i.e. full version?

if want file version of root block, forget language specific translation:

function fileversion(const filename: tfilename): string; var   verinfosize: cardinal;   vervaluesize: cardinal;   dummy: cardinal;   pverinfo: pointer;   pvervalue: pvsfixedfileinfo; begin   result := '';   verinfosize := getfileversioninfosize(pchar(filename), dummy);   getmem(pverinfo, verinfosize);   try     if getfileversioninfo(pchar(filename), 0, verinfosize, pverinfo)       if verqueryvalue(pverinfo, '\', pointer(pvervalue), vervaluesize)         pvervalue^           result := format('v%d.%d.%d build %d', [             hiword(dwfileversionms), //major             loword(dwfileversionms), //minor             hiword(dwfileversionls), //release             loword(dwfileversionls)]); //build       freemem(pverinfo, verinfosize);   end; end; 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -