I’m developing a windows app (it depends on DirectShow, so no Linux, etc).
It will run, for now, in XP and Windows 7 (no Vista support).
However, there’s a piece of code that behaves very differently in XP or Windows 7, so I need to know in which system I am, to make a workaround. As I don’t support Vista -and even if I did, I guess there wouldn’t be much differences- I don’t care if Vista and 7 are identified as the same OS, although I’d prefer they weren’t.
Just in case, I’m developing in c++, and I don’t want to maintain two different executables, and I’d prefer a language-agnostic way to do it.
So, my question: What’s The Right Way(tm) to check at run-time which windows version is running?
The article referenced by Naveen has an important remark, that might be relevant for your scenario, too:
Checking for a particular feature can be done using the
IsOSfunction.GetVersionExcan be used to retrieve the OS version. However, be aware that the OS will identify differently depending on whether compatibility mode is in effect or not.