I wrote:
> 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
Microsoft documentation for GetVersion claims:
For all platforms, the low-order word contains the version number of the
operating system.
The low-order byte of this word specifies the major version number, in
hexadecimal notation.
The high-order byte specifies the minor version (revision) number, in
hexadecimal notation.
(NOTE: the following describes high-order word of returned DWORD value,
which is unclean from wording in the documentation)
The high-order bit is zero, the next 7 bits represent the build number, and
the low-order byte is 5.
The last sentence does not hold water on anything newer than Windows XP; both
bytes of high-order word, in isolation, are meaningless. For example, this is
what I get by printing all bytes on my Windows 11 machine:
$ cat get_version.c
#include <wchar.h>
#include <windows.h>
int main (void) {
DWORD version = GetVersion ();
BYTE highWordHighByte = HIBYTE(HIWORD(version));
BYTE highWordLowByte = LOBYTE(HIWORD(version));
BYTE lowWordHighByte = HIBYTE(LOWORD(version));
BYTE lowWordLowByte = LOBYTE(LOWORD(version));
wprintf (L"%d | %d | %d | %d\n", lowWordLowByte, lowWordHighByte,
highWordLowByte, highWordHighByte);
return 0;
}
$ ./a.exe
10 | 0 | 88 | 102
However, if I print the high word as a whole (5th column):
$ ./a.exe
10 | 0 | 88 | 102 | 26200
It corresponds to the build number. What a mess...
- Kirill Makurin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public