Title: Get de version number of executable
Question: I want show the build version of exe file on the caption in my application, because it grow very fast...
Answer:
function MyAppVersion:string;
var
intSize, intIndice : Integer;
dwdDummy : DWord;
uinSize : UINT;
pchInfo : PChar;
pntValor : Pointer;
pntTranslation : Pointer;
strBegin : String;
begin
intSize := GetFileVersionInfoSize(PChar(ParamStr(0)),dwdDummy);
if intSize 0 then
begin
GetMem(pchInfo,intSize);
GetFileVersionInfo(PChar(ParamStr(0)),0,intSize,pchInfo);
VerQueryValue(pchInfo,'\\VarFileInfo\\Translation',pntTranslation,uinSize);
strBegin := '\\StringFileInfo\\'+ IntToHex(LoWord(LongInt(pntTranslation^)),4)+ IntToHex(HiWord(LongInt(pntTranslation^)),4)+'\\';
for intIndice:=1 to 11 do
if VerQueryValue(pchInfo,PChar(strBegin+'FileVersion'),pntValor,uinSize) then
if (uinSize 0) and (intIndice=3) then begin
result := String(PChar(pntValor));
end;
FreeMem(pchInfo,intSize);
end;
end;