Kylix
Tips

NEW TIPS
Database (94)
Files (875)
Forms (120)
Graphic (121)
IDE (28)
Indy (13)
Internet / LAN (142)
IntraWeb (9)
Kylix (19)
Math (84)
Misc (137)
Multimedia (56)
Objects/
ActiveX (63)

OpenTools API (11)
Printing (45)
Strings (94)
System (274)
VCL (246)

Search Tip
Top15
Add new Tip

Forum

...read the version of a file?
Author: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
[ Print tip ]    

Tip Rating (28):  
     



function GetVersion: string;
var
  
VerInfoSize: DWORD;
  VerInfo: Pointer;
  VerValueSize: DWORD;
  VerValue: PVSFixedFileInfo;
  Dummy: DWORD;
begin
  
Result := '';
  VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
  if VerInfoSize = 0 then Exit;
  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;

Rate this tip:

poor
very good


Copyright © Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright © 1996-2001