Good evening Cboard!
So, this is a pretty basic question, but it has been frustrating me for a while now. I am trying to programatically determine which Windows OS my program is running on. I am already aware of various APIs that are designed to achieve this, namely the GetVersion() and GetVersionEx() functions, along with their successor Version Helper functions defined in <versionhelpers.h>.
My issue with the former two functions is that they seem to 'chop and change' from OS to OS and I'm looking to make my code as "Windows-portable" as possible (ideally even extending back to the Windows 95 era). For instance, MSDN states that "Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2)". This sort of inconsistency is hopefully avoidable; I am really disappointed in Microsoft for no longer abiding by their prior backwards-compatibility ethos.
That leads me on to the Version Helper functions. Unfortunately, programming is only a hobby of mine and, as such, I am reluctant to spend money on the go-to professional IDE, Visual Studio. I am aware that a free Express version exists, however, a few reviews of the software claim that it is an absolute nightmare to work with a "crippled" (i.e. restricted,) IDE. At the moment, I am working with the latest version of CodeBlocks, which ships with outdated Windows headers, ruling out the use of Version Helper functions. (There is, of course, the Windows SDK, but having installed it in the past, it seems that CodeBlocks just doesn't like it. A lot of errors are thrown from just including Windows.h from the SDK. Also, I'm not going to lie; I've even considered using a cracked version of Visual Studio to get the job done, but I try very hard to avoid pirated software unless ABSOLUTELY necessary.)
So I guess my questions is: "Any ideas?". Maybe it would be feasible to code my own OS fingerprinting function/library by perhaps scanning the filesystem and registry for entries that are unique to each individual version of Windows. This would, however, be very difficult as I only really have access to Windows Vista/7/8 machines; I'm unsure of how I can discover unique "artefacts" with which I can identify the other operating systems. Short of putting significant effort into creating such a codebase and re-inventing the wheel, I'm at a loss as to what I can do.
Any suggestions would be hugely appreciated!
Many thanks,
Abyssion