Sign in Join
Wiki copytemporary

Revision 2 of 3, by WikiArchive on 11-4-2026. The page as it is now.

GetCurrentVersion

https://upload.wikimedia.org/wikipedia/commons/thumb/5/5f/Windows_logo_-_2012.svg/50px-Windows_logo_-_2012.svg.png

This article applies to Windows only.

See also: Multiplatform Programming Guide

│ Deutsch (de) │ English (en) │


Return to the Code Examples page.

This article deals with Windows programming.

The function determines the current version of your own program.

pascal
uses
       Windows, SysUtils, ...;
    
       ...
    
     function funGetCurrentVersion: string;
     var
       lwdVerInfoSize: longword;
       lwdVerValueSize: longword;
       lwdDummy: longword;
       ptrVerInfo: pointer;
       VersionsInformation: PVSFixedFileInfo;
    
     begin
    
       lwdVerInfoSize: = GetFileVersionInfoSize(PChar(ParamStr(0)), lwdDummy);
       GetMem(ptrVerInfo, lwdVerInfoSize);
       GetFileVersionInfo(PChar(ParamStr(0)), 0, lwdVerInfoSize, ptrVerInfo);
       VerQueryValue (ptrVerInfo, '\', Pointer(VersionsInformation), lwdVerValueSize);
    
       with VersionsInformation^ 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(ptrVerInfo, lwdVerInfoSize);
    
     end;
    
     ...

From the Free Pascal wiki, page "GetCurrentVersion", as the Internet Archive kept it on 2024-09-14. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.