CauldronDevelopmentLLC / cbang

C! (cbang) is a library for cross-platform C++ development.
GNU Lesser General Public License v2.1
56 stars 39 forks source link

Update Win getOSVersion() #133

Closed kbernhagen closed 10 months ago

kbernhagen commented 10 months ago

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.

kbernhagen commented 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.

marcosfrm commented 10 months ago

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

kbernhagen commented 10 months ago

Yes, better, thanks. I will use that. With a fallback, as suggested, because it’s undocumented.

marcosfrm commented 10 months ago

These undocumented Windows APIs will exist until hell freezes over. 🤣

kbernhagen commented 10 months ago

Although seemingly working, this was a WIP. I’ll make improvements in another PR.