Function VersaoExe: String; type
PFFI = ^vs_FixedFileInfo; var
F : PFFI;
Handle : Dword;
Len : Longint;
Data : Pchar;
Buffer : Pointer;
Tamanho : Dword;
Parquivo: Pchar;
Arquivo : String; begin
Arquivo := Application.ExeName;
Parquivo := StrAlloc(Length(Arquivo) + 1);
StrPcopy(Parquivo, Arquivo);
Len := GetFileVersionInfoSize(Parquivo, Handle);
Result := ''; if Len > 0 then begin
Data:=StrAlloc(Len+1); if GetFileVersionInfo(Parquivo,Handle,Len,Data) then begin
VerQueryValue(Data, '',Buffer,Tamanho);
F := PFFI(Buffer);
Result := Format('%d.%d.%d.%d',
[HiWord(F^.dwFileVersionMs),
LoWord(F^.dwFileVersionMs),
HiWord(F^.dwFileVersionLs),
Loword(F^.dwFileVersionLs)]
); end;
StrDispose(Data); end;
StrDispose(Parquivo); end;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
function VersaoExe: String;
private
{ Private declarations } public { Public declarations } end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin
ShowMessage(VersaoExe); end;
function VersaoExe: String; type
PFFI = ^vs_FixedFileInfo; var
F : PFFI;
Handle : Dword;
Len : Longint;
Data : Pchar;
Buffer : Pointer;
Tamanho : Dword;
Parquivo: Pchar;
Arquivo : String; begin
Arquivo := Application.ExeName;
Parquivo := StrAlloc(Length(Arquivo) + 1);
StrPcopy(Parquivo, Arquivo);
Len := GetFileVersionInfoSize(Parquivo, Handle);
Result := ''; if Len > 0 then begin
Data:=StrAlloc(Len+1); if GetFileVersionInfo(Parquivo,Handle,Len,Data) then begin
VerQueryValue(Data, '',Buffer,Tamanho);
F := PFFI(Buffer);
Result := Format('%d.%d.%d.%d',
[HiWord(F^.dwFileVersionMs),
LoWord(F^.dwFileVersionMs),
HiWord(F^.dwFileVersionLs),
Loword(F^.dwFileVersionLs)]
); end;
StrDispose(Data); end;
StrDispose(Parquivo); end;