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
| function ApplicationVersion: String;
var
VerInfoSize, VerValueSize, Dummy: DWord;
VerInfo: Pointer;
VerValue: PVSFixedFileInfo;
begin
VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
{Deux solutions : }
if VerInfoSize <> 0 then
{- Les info de version sont inclues }
begin
{On alloue de la mémoire pour un pointeur sur les info de version : }
GetMem(VerInfo, VerInfoSize);
{On récupère ces informations : }
GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo);
VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
{On traite les informations ainsi récupérées : }
with VerValue^ do
begin
Result := IntTostr(dwFileVersionMS shr 16);
Result := Result + '.' + IntTostr(dwFileVersionMS and $FFFF);
Result := Result + '.' + IntTostr(dwFileVersionLS shr 16);
Result := Result + '.' + IntTostr(dwFileVersionLS and $FFFF);
end;
{On libère la place précédemment allouée : }
FreeMem(VerInfo, VerInfoSize);
end
else
{- Les infos de version ne sont pas inclues }
{On déclenche une exception dans le programme : }
raise EAccessViolation.Create('Les informations de version de sont pas inclues');
end; |
Partager