Created
September 17, 2015 14:11
-
-
Save ILPlais/8b774662b238cbcddb33 to your computer and use it in GitHub Desktop.
Retourne les informations de version d'un applicatif déterminé
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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