Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Jul : File Version sample

www.cryer.info
Managed Newsgroup Archive

File Version sample

Subject:File Version sample
Posted by:"Sergio Pottstock" (pt..@pttk.cl)
Date:Thu, 7 Jul 2005 15:09:52

Hi,

I try use the sample in help file for read FILE version, but not work

Any Idea?

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: DWORD;
  Buf: PChar;
  Value: PChar;
begin
  S := Application.ExeName;
  n := GetFileVersionInfoSize(PChar(S), n);
  if n > 0 then
  begin

    Buf := AllocMem(n);
    Memo1.Lines.Add('VersionInfoSize = ' + 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 version information found');
end;

Thank

PTTK

www.pttk.cl

Replies:

www.cryer.info
Managed Newsgroup Archive