Kylix
Tips

NEW TIPS
Database (98)
Files (1187)
Forms (125)
Graphic (126)
IDE (30)
Indy (13)
Internet / LAN (146)
IntraWeb (12)
Math (84)
Misc (137)
Multimedia (56)
Objects/
ActiveX (64)

OpenTools API (14)
Printing (47)
Strings (94)
System (275)
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 (29):  
     



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