unit AplicacionInfo;
interface
uses Windows, Classes, SysUtils;
type
TVersionInfo = class(TObject)
private
FData: Pointer;
FSize: Cardinal;
FNombreCompania: string;
FDescripcionDelArchivo: string;
FVersionDelArchivo: string;
FNombreInterno: string;
FDerechosDeCopiado: string;
FMarcasRegistradas: string;
FNombreOriginalDelArchivo: string;
FNombreDelProducto: string;
FVersionDelProducto: string;
FComentarios: string;
FVersionInterna: Integer;
public
constructor Create(FileName: string); Overload;
constructor Create; Overload;
destructor Destroy; override;
property NombreCompania: string read FNombreCompania;
property DescripcionDelArchivo: string read FDescripcionDelArchivo;
property VersionDelArchivo: string read FVersionDelArchivo;
property NombreInterno: string read FNombreInterno;
property DerechosDeCopiado: string read FDerechosDeCopiado;
property MarcasRegistradas: string read FMarcasRegistradas;
property NombreOriginalDelArchivo: string read FNombreOriginalDelArchivo;
property NombreDelProducto: string read FNombreDelProducto;
property VersionDelProducto: string read FVersionDelProducto;
property Comentarios: string read FComentarios;
property VersionInterna: Integer read FVersionInterna;
end;
implementation
constructor TVersionInfo.Create(FileName: string);
var
sz, lpHandle, tbl: Cardinal;
lpBuffer: Pointer;
str: PChar;
strtbl: string;
int: PInteger;
hiW, loW: Word;
Function Leer(Const pcValor: String): String;
Begin
VerQueryValue(FData, PChar('\\StringFileInfo\' + strtbl + pcValor), lpBuffer, sz);
str := lpBuffer;
Result := str;
End;
begin
inherited Create;
FSize := GetFileVersionInfoSize(PChar(FileName), lpHandle);
FData := AllocMem(FSize);
GetFileVersionInfo(PChar(FileName), lpHandle, FSize, FData);
VerQueryValue(FData, '\\VarFileInfo\Translation', lpBuffer, sz);
int := lpBuffer;
hiW := HiWord(int^);
loW := LoWord(int^);
tbl := (loW shl 16) or hiW;
strtbl := Format('%x', [tbl]);
if Length(strtbl) < 8 then
strtbl := '0' + strtbl;
FNombreCompania := Leer('\CompanyName');
FDescripcionDelArchivo := Leer('\FileDescription');
FVersionDelArchivo := Leer('\FileVersion');
FNombreInterno := Leer('\InternalName');
FDerechosDeCopiado := Leer('\LegalCopyright');
FMarcasRegistradas := Leer('\LegalTrademarks');
FNombreOriginalDelArchivo := Leer('\OriginalFilename');
FNombreDelProducto := Leer('\ProductName');
FVersionDelProducto := Leer('\ProductVersion');
FComentarios := Leer('\Comments');
FVersionInterna := StrToInt(Leer('\VersionInterna'));
end;
constructor TVersionInfo.Create;
begin
Create(ParamStr(0));
end;
destructor TVersionInfo.Destroy;
begin
FreeMem(FData);
inherited;
end;
end.