GetCurrentVersion: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 1 | + | Return to the [[Code Examples|Code Examples page]]. | |
| 2 | 2 | ||
| 3 | - | ||
| 3 | + | This article deals with Windows programming. | |
| 4 | 4 | ||
| 5 | - | ||
| 5 | + | The function determines the current version of your own program. | |
| 6 | 6 | ||
| 7 | - | ||
| 8 | - | ||
| 7 | + | ``` pascal | |
| 8 | + | uses | |
| 9 | + | Windows, SysUtils, ...; | |
| 9 | 10 | ||
| 10 | - | ||
| 11 | + | ... | |
| 11 | 12 | ||
| 12 | - | ||
| 13 | + | function funGetCurrentVersion: string; | |
| 14 | + | var | |
| 15 | + | lwdVerInfoSize: longword; | |
| 16 | + | lwdVerValueSize: longword; | |
| 17 | + | lwdDummy: longword; | |
| 18 | + | ptrVerInfo: pointer; | |
| 19 | + | VersionsInformation: PVSFixedFileInfo; | |
| 13 | 20 | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - | ||
| 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 | + | ... | |
| 49 | 41 | ``` | |
| 50 | 42 | ||
| 51 | 43 | --- | |
| 52 | - | ||
| 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).* |
