Sign in Join
Wiki copytemporary

Windows version: what changed

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

Title: Windows version

OldNewLine
1+*(Windows only)*
2+
3+This article is about Windows programming. Obtaining information on the version of the running Windows instance is important for many purposes.
4+
5+## Using Windows unit
6+
7+The function below is intended for older versions. It determines the version of the current Windows installation. Please note that the GetVersion function is deprecated in Windows 8.1 and newer versions. More universal approach is using SysUtils unit variables, as shown below.
8+
9+``` pascal
10+uses
11+ Windows, SysUtils, ...;
12+ ...
13+{
14+Meaning of Windows version numbers:
15+5.0 => Windows 2000
16+5.1 => Windows XP
17+5.2 => Windows XP64 or Windows 2003 Server
18+6.0 => Windows Vista or Windows 2008 Server
19+6.1 => Windows 7 or Windows 2008 Server R2
20+6.2 => Windows 8 or Windows Server 2012
21+6.3 => Windows 8.1 or Windows Server 2012 RS
22+}
23+
24+function GetWinVersion: string;
25+begin
26+ Result :=
27+ IntToStr(LOBYTE(LOWORD(GetVersion))) + '.' +
28+ IntToStr(HIBYTE(LOWORD(GetVersion)));
29+end;
30+```
31+
32+## Using SysUtils variables
33+
34+The SysUtils unit provides the Windows version information in several variables:
35+
36+``` pascal
37+uses SysUtils;
38+begin
39+ Writeln('Win32 Platform : ', Win32Platform );
40+ Writeln('Win32 Major Version: ', Win32MajorVersion);
41+ Writeln('Win32 Minor Version: ', Win32MinorVersion);
42+ Writeln('Win32 Build Number : ', Win32BuildNumber );
43+ Writeln('Win32 CSD Version : ', Win32CSDVersion );
44+ Readln;
45+end.
46+```
47+
48+The output looks like this for Windows 7 Service Pack 1:
49+
50+ Win32 Platform : 2
51+ Win32 Major Version: 6
52+ Win32 Minor Version: 1
53+ Win32 Build Number : 7601
54+ Win32 CSD Version : Service Pack 1
55+
56+The output looks like this for Windows 10 Pro Build 18362 (64 bit):
57+
58+ Win32 Platform : 2
59+ Win32 Major Version: 6
60+ Win32 Minor Version: 2
61+ Win32 Build Number : 9200
62+ Win32 CSD Version :
63+
64+## Using Win32Proc Lazarus unit
65+
66+The following works for identifying Windows 11 and all older versions:
67+
68+``` pascal
69+uses ..., Win32Proc;
70+
71+function GetWinVersion: string;
72+begin
73+ case WindowsVersion of
74+ wv95: Result:= 'Windows 95';
75+ wvNT4: Result:= 'Windows NT v.4';
76+ //etc.
77+ //see possible values in the unit "win32proc" in "lcl/interfaces/win32/win32proc.pp"
78+ end;
79+end.
80+```
81+
82+## References
83+
84+1. Windows Developer: [Operating system version changes in Windows 8.1 and Windows Server 2012 R2](https://docs.microsoft.com/en-us/windows/win32/w8cookbook/operating-system-version-changes-in-windows-8-1?redirectedfrom=MSDN). 05/31/2018
85+
86+---
87+*From the Free Pascal wiki, page "Windows version", as it stood on 2023-10-10 after a change by Alextpp, 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