[DUG] Version number

Trevor Jones trevorj at ihug.co.nz
Fri Nov 3 13:57:43 NZDT 2006


John,
  This will get the version number as an int64 which you can use for
comparisons.  I guess you can modify it to retrieve the 4 individual 16 bit
entries that go between the dots.

function GetFileVersion(const Filename: string): int64;
var
  VersionInfoSize		: integer;
  VersionInfoHandle   : DWORD;
   VersionInfo	: string;
    szName		  : array[0..255] of char;
    FixedFileInfo   : PVSFixedFileInfo;
		BufferLen			: UINT;
begin
  result := 0;
  VersionInfoSize := GetFileVersionInfoSize(
				pChar( Filename),
				VersionInfoHandle );
  if VersionInfoSize > 0 then
    begin
    SetLength( VersionInfo, VersionInfoSize );
    BufferLen := sizeof(TVSFixedFileInfo);
    if GetFileVersionInfo( pChar( FileName),
		VersionInfoHandle,
		VersionInfoSize,
		pChar( VersionInfo )) then
      if VerQueryValue( pChar( VersionInfo ),
                        StrPCopy(szName,'\'),
                        pointer(FixedFileInfo),
                        BufferLen) and (BufferLen > 0) then
        begin
        result := FixedFileInfo.dwFileVersionMS;
        result := result shl 32;
        result := result + FixedFileInfo.dwFileVersionLS;
        end;
    end;
end;

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of John Bird
Sent: Friday, 3 November 2006 11:50 a.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: [DUG] Version number

How do I get the current program version number from inside a program at
runtime (the one that can be set to auto-increment in the builds in Options)

John


_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi




More information about the Delphi mailing list