- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


3241:Getting Version Information From Your Program

KEYWORDS: Version, info, application, getversioninfo AREA: Application Interop

This sample project demonstrates how to get at the version info
in executables.

1. Launch Delphi 3.

2. In a new project, drop a TMemo and a TButton on the form (make
   sure they're called Memo1 and Button1). Double click on Button1.
   Now you can go ahead and directly replace the code for the
   Button1Click procedure (see below).

--------------------------
The Button1Click procedure
--------------------------

procedure TForm1.Button1Click(Sender: TObject);
const
  InfoNum = 10;
  InfoStr : array [1..InfoNum] of String =
    ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName',
     'LegalCopyright', 'LegalTradeMarks', 'OriginalFilename',
     'ProductName', 'ProductVersion', 'Comments');
var
  S         : String;
  n, Len, i : Integer;
  Buf       : PChar;
  Value     : PChar;
begin
  S := Application.ExeName;
  n := GetFileVersionInfoSize(PChar(S),n);
  if n > 0 then begin
    Buf := AllocMem(n);
    Memo1.Lines.Add('FileVersionInfoSize='+IntToStr(n));
    GetFileVersionInfo(PChar(S),0,n,Buf);
    for i:=1 to InfoNum do
      if VerQueryValue(Buf,PChar('StringFileInfo\040904E4\'+
                                 InfoStr[i]),Pointer(Value),Len) then
        Memo1.Lines.Add(InfoStr[i]+'='+Value);
    FreeMem(Buf,n);
  end else
    Memo1.Lines.Add('No FileVersionInfo found');
end;

        TI



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile