Skip to content

Commit 23529c0

Browse files
committed
gh-152433: Windows: _winapi.c implement GetVersion() UWP alternative
1 parent ecdef17 commit 23529c0

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``_winapi``: implement ``GetVersion()`` UWP alternative.

Modules/_winapi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,19 @@ _winapi_GetVersion_impl(PyObject *module)
17391739
#pragma warning(disable:4996)
17401740

17411741
{
1742+
#ifdef MS_WINDOWS_DESKTOP
17421743
return GetVersion();
1744+
#else
1745+
OSVERSIONINFOW version_info;
1746+
ZeroMemory(&version_info, sizeof(version_info));
1747+
version_info.dwOSVersionInfoSize = sizeof(version_info);
1748+
if (GetVersionExW(&version_info)) {
1749+
return version_info.dwMinorVersion |
1750+
(version_info.dwMajorVersion << 8) |
1751+
(version_info.dwBuildNumber << 16);
1752+
}
1753+
return 0;
1754+
#endif
17431755
}
17441756

17451757
#pragma warning(pop)

0 commit comments

Comments
 (0)