Como en otras ocasiones voy a echar mano de la API de Windows:
GetFileVersionInfoSize
GetFileVersionInfo
VerQueryValue
Aquí un ejemplo de código:
uses Windows, ...; type TVersion = record major: DWORD; minor: DWORD; release: DWORD; build: DWORD; end; implementation function GetVersion(FileName: String; var Version: TVersion): boolean; var dwHandle: DWORD; verInfo: PVSFIXEDFILEINFO; Data: Pointer; verSize, dataSize: DWORD; begin Result:= false; ZeroMemory(@Version, sizeof(TVersion)); dwHandle:= 0; dataSize:= GetFileVersionInfoSize(PCHAR(FileName), dwHandle); GetMem(Data, dataSize); if GetFileVersionInfo(PCHAR(FileName), dwHandle, dataSize, Data) then begin if VerQueryValue(Data, '\', Pointer(verInfo), verSize) then begin if verSize > 0 then begin if verInfo.dwSignature = $FEEF04BD then begin Version.major:= verInfo.dwFileVersionMS shr 16; Version.minor:= verInfo.dwFileVersionMS and $FFFF; Version.release:= verInfo.dwFileVersionLS shr 16; Version.build:= verInfo.dwFileVersionLS and $FFFF; Result:= true; end; end; end; end; FreeMem(Data); end; function GetVersionString(FileName: String): String; var Version: TVersion; begin GetVersion(FileName, Version); Result:= Format('%d.%d.%d.%d', [Version.major, Version.minor, Version.release, Version.build]); end;
Un ejemplo de uso para conocer la versión de nuestra propia App:
Label1.Caption:= GetVersionString(ParamStr(0));
Saludos.