GetCurrentVersion
Deutsch ยท English
Return to the Code Examples page.
This article deals with Windows programming.
The function determines the current version of your own program.
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 it stood on 2020-02-16 after a change by Trev, out of the wiki's dump of 2024-05-26. 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.