1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
function GetVersion: string;
var
FileName : string;
VersionInfo: DWORD;
InfoSize : Cardinal;
InfoData : array of Byte;
FixedInfo : PVSFixedFileInfo;
Version : PChar;
begin
Result := 'DEBUG';
FileName := ParamStr(0);
InfoSize := GetFileVersionInfoSize(PChar(FileName), VersionInfo);
if InfoSize = 0 then
Exit;
SetLength(InfoData, InfoSize);
if not GetFileVersionInfo(PChar(FileName), VersionInfo, InfoSize, @InfoData[0]) then
Exit;
if not VerQueryValue(@InfoData[0], '\', Pointer(FixedInfo), InfoSize) then
Exit;
// version textuelle ?
if Loword(FixedInfo.dwProductVersionLS) = 0 then
begin
if VerQueryValue(@InfoData[0], '\StringFileInfo\040C04E4\ProductVersion', Pointer(Version), InfoSize) then
begin
Result := 'V' + Version;
Exit;
end;
end;
// sinon construire un numéro de version binaire
Result := Format('V%d.%d.%d', [Hiword(FixedInfo.dwProductVersionMS), Loword(FixedInfo.dwProductVersionMS), Hiword(FixedInfo.dwProductVersionLS)]);
// avec des Release Candidates
if Loword(FixedInfo.dwProductVersionLS) <> 0 then
Result := Result + ' RC' + IntToStr(Loword(FixedInfo.dwProductVersionLS));
end; |
Partager