How to detect OS of Win7 Home Premium, Win7 Professional, Win7 Enterprise or Win7 ultimate?
views:
452answers:
7Determine Windows Version and Edition
Check this post Detect OS version and see if it helps. This is for XP but it should help you little bit.
Check this one too http://andrewensley.com/2009/06/c-detect-windows-os-part-1/ and this one is for Vista.
Try WMI: host localhost
, namespace root\cimv2
(these are the defaults) SELECT Caption FROM Win32_OperatingSystem
He tagged the question with win32 api.
GetVersionEx() et al. is what you need. See this code sample for a more in depth example.
I'm using the key "Edition" under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion to determine windows version, I don't know if it's unique? Thanks.
EditionID = ultimate EditionID = Enterprise EditionID = Professional EditionID = Premium
Using approach like checking the version number is incorrect in my opinion. I was reading an article about best practices (lost the link) and it clearly said never use these version numbers which microsoft may change in future updates to detect windows version.
Windows Vista is version 6.0 and Windows 7 is 6.1 which ideally should have been 7. This is not a reliable at all.
A better way is to check the existance of features which are particular to each version of windows. For ex, in windows vista/7 home basic you would not find aero experience. Same way ultimate edition comes with bitlocker etc and home premium doesnt.
MSDN will detail what features are available in each version and how to query if its available. Based on this you can decide what is the base version of windows. Also you can use to query version info from the system dlls to detect exact windows build date etc.
With windows 7 new DLLs have been added in the system32 as compared to vista. So when you search for particular dlls you would know if its windows 7 system or old versions like xp/vista.
You can use GetVersionEx to determine the core OS version, but this method gets messy faced with multiple products which use a common core, and I don't think you can programatically decode this information down to the level of a particular SKU. The best you could get away with is finding a string and letting the user see that. Some simple OSVERSIONINFOEX mappings are shown in the remarks section of the docs here
Read this Microsoft blog posting for current thinking on this topic. Basically it comes down to using GetProcAddress to look for the API you're trying to use and degrading gracefully.