Sign in Join
Wiki copytemporary

GetCurrentVersion: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: GetCurrentVersion

OldNewLine
1+Return to the [[Code Examples|Code Examples page]].
2+
3+This article deals with Windows programming.
4+
5+The function determines the current version of your own program.
6+
7+``` pascal
8+ uses
9+ Windows, SysUtils, ...;
10+
11+ ...
12+
13+ function funGetCurrentVersion: string;
14+ var
15+ lwdVerInfoSize: longword;
16+ lwdVerValueSize: longword;
17+ lwdDummy: longword;
18+ ptrVerInfo: pointer;
19+ VersionsInformation: PVSFixedFileInfo;
20+
21+ begin
22+
23+ lwdVerInfoSize: = GetFileVersionInfoSize(PChar(ParamStr(0)), lwdDummy);
24+ GetMem(ptrVerInfo, lwdVerInfoSize);
25+ GetFileVersionInfo(PChar(ParamStr(0)), 0, lwdVerInfoSize, ptrVerInfo);
26+ VerQueryValue (ptrVerInfo, '\', Pointer(VersionsInformation), lwdVerValueSize);
27+
28+ with VersionsInformation^ do
29+ begin
30+ Result: = IntToStr (dwFileVersionMS shr 16);
31+ Result: = Result + '.' + IntToStr(dwFileVersionMS and $ FFFF);
32+ Result: = Result + '.' + IntToStr(dwFileVersionLS shr 16);
33+ Result: = Result + '.' + IntToStr(dwFileVersionLS and $ FFFF);
34+ end;
35+
36+ FreeMem(ptrVerInfo, lwdVerInfoSize);
37+
38+ end;
39+
40+ ...
41+```
42+
43+---
44+*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](/wiki-contact).*

Back to history