On Thursday 05 March 2026 05:19:09 Kirill Makurin wrote:
> Hi Pali and all,
> 
> I was reading through Microsoft docs for GetVersion[1], GetVersionEx[2] and 
> related stuff.
> 
> [1] 
> https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversion
> [2] 
> https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexw
> 
> This article[3] lists version numbers for all Windows versions back to 
> Windows 2000; do you know what are these for pre-2000? In particular NT 4.0, 
> NT 3.51, NT 3.5, NT 3.1 and all the Win9x.
> 
> [3] 
> https://learn.microsoft.com/en-us/windows/win32/sysinfo/operating-system-version
> 
> Another interesting detail I've noticed is that GetVersionEx sets 
> `dwPlatformId` member of OSVERSIONINFO* structures to 
> `VER_PLATFORM_WIN32_NT`; this makes me wonder if there was a separate value 
> to identify Win9x systems?
> 
> Also, our lib32/kernel32.def says that GetVersionEx is available in all Win9x 
> and only since NT 3.5, which means in some cases I may need to check for its 
> presence at runtime as well :)
> 
> - Kirill Makurin

Hello, in past I was looking at GetVersion and GetVersionEx functions
and I was inspecting how they works. So I think I should have all those
information for which you are asking.

Microsoft started removing most of documentation for GetVersion and
GetVersionEx functions, but web archive has copy of it before removal:

https://web.archive.org/web/20041209205313/http://msdn.microsoft.com/library/en-us/sysinfo/base/getversion.asp
https://web.archive.org/web/20020905235730/http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp

On internet can be found various dumps of WinSDK documentation,
like from WIN32.HLP file. For example these:

https://winapi.freetechsecrets.com/win32/WIN32GetVersion.htm
https://winapi.freetechsecrets.com/win32/WIN32GetVersionEx.htm

https://library.thedatadungeon.com/msdn-2000-04/sysmgmt/hh/sysmgmt/sysinfo_41bi.htm
https://library.thedatadungeon.com/msdn-2000-04/sysmgmt/hh/sysmgmt/sysinfo_49iw.htm

Also there are some undocumented parts of GetVersion function, specially
what is filled in reserved bits. I was running different tests in the
past and here is hopefully the full documentation. I was also checking
the wine sources in past and it confirms it.

GetVersion returns DWORD with these bits:
[31:30] - PlatformId XORed with 0b10
[29:16] - BuildNumber
[15:08] - MinorVersion
[07:00] - MajorVersion

The highest bit [31] is also indicating (when set) if the OS is DOS based.

GetVersionEx is returning what is written in MS documentation, just
compared with GetVersion, on Win32s is GetVersionEx returning the
Win32s version (1.30), and GetVersion is returning OS version (3.11).

PlatformId is one of:
VER_PLATFORM_WIN32s - Win32s
VER_PLATFORM_WIN32_WINDOWS - Win9x
VER_PLATFORM_WIN32_NT - WinNT
(in both GetVersionEx and GetVersion, just be aware of XOR 0b10)

There is also VER_PLATFORM_WIN32_CE which indicates Windows CE
implementation , but Windows CE does not support running PE
IMAGE_SUBSYSTEM_WINDOWS_GUI and PE IMAGE_SUBSYSTEM_WINDOWS_CUI binaries
and it also does not have GetVersion function at all. Only GetVersionEx.
So mostly you can ignore CE.

Therefore if you want to check for all possible OS system variants, the
GetVersion() function is universal, available on all implementations and
contains mostly everything what you need.


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to