Closed kbernhagen closed 10 months ago
I don't know if this would fail on a non-Pro install of Windows.
It might be reasonable to keep the old code as a fallback.
RtlGetNtVersionNumbers()
(available since Windows XP) is better:
https://github.com/golang/sys/commit/fb81701db80f1745f51259b1f286de3fe2ec80c8 https://www.geoffchappell.com/studies/windows/win32/ntdll/api/ldrinit/getntversionnumbers.htm
Example:
https://dennisbabkin.com/blog/?t=how-to-tell-the-real-version-of-windows-your-app-is-running-on
Yes, better, thanks. I will use that. With a fallback, as suggested, because it’s undocumented.
These undocumented Windows APIs will exist until hell freezes over. 🤣
Although seemingly working, this was a WIP. I’ll make improvements in another PR.
WIP
This tested ok on Win 10 (unlicensed) and 7 Pro.
GetVersionEx() is deprecated and never gives version greater than 6.2. Some other methods exist, but can lie based on app manifest.