Skip to content

Instantly share code, notes, and snippets.

@ILPlais
Created September 17, 2015 14:11
Show Gist options
  • Select an option

  • Save ILPlais/8b774662b238cbcddb33 to your computer and use it in GitHub Desktop.

Select an option

Save ILPlais/8b774662b238cbcddb33 to your computer and use it in GitHub Desktop.
Retourne les informations de version d'un applicatif déterminé
procedure InfosVersion(Fichier: String;
out Majeure, Mineure, Release, Build: Integer);
var
VerInfoSize, VerValueSize, Dummy: DWord;
VerInfo: Pointer;
VerValue: PVSFixedFileInfo;
begin
// Récupère la taille des infos de version
VerInfoSize := GetFileVersionInfoSize(Pchar(Fichier), Dummy);
// Les infos de version sont inclues
if VerInfoSize <> 0 then
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(Fichier), 0, VerInfoSize, VerInfo);
VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
// On traite les informations ainsi récupérées
with VerValue^ do
begin
Majeure := dwFileVersionMS shr 16;
Mineure := dwFileVersionMS and $FFFF;
Release := dwFileVersionLS shr 16;
Build := dwFileVersionLS and $FFFF;
end;
// On libère la place précédemment allouée
FreeMem(VerInfo, VerInfoSize);
end
else
begin
// Si les infos de version ne sont pas inclues
Majeure := -1;
Mineure := -1;
Release := -1;
Build := -1;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment