[TRUCOS DELPHI] Leer la version de un archivo.
delphi
function GetVersion : String; var VerInfoSize: DWord; VerInfo: Pointer; VerValueSize: DWord; VerValue: PVSFixedFileInfo; Dummy: DWord; begin VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy); GetMem(VerInfo, VerInfoSize); GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo); VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize); 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; FreeMem(VerInfo, VerInfoSize); end;
Ejemplo de uso:
delphi
procedure Form1.Button1Click(Sender:TObject); begin Label1.Caption:=GetVersion; end;
Saludos!