I have to detect Windows 8 Operating system in my C# Windows Application and do some settings. I know we can detect Windows 7 using Environment.OSVersion
, but how can windows 8 be detected?
Thanks in advance.
Find operating system info in Windows 8.1 or Windows RT 8.1 To find out which version of Windows your device is running, press the Windows logo key key + R, type winver in the Open box, and then select OK.
Software Engineering C To check the operating system of the host in a C or C++ code, we need to check the macros defined by the compiler (GNU GCC or G++). For example, on Windows platform, the compiler has a special macro named _WIN32 defined. So, if the macro _WIN32 is defined, we are on Windows.
For those who care about such things: Many have asked whether Windows is written in C or C++. The answer is that - despite NT's Object-Based design - like most OS', Windows is almost entirely written in 'C'. Why? C++ introduces a cost in terms of memory footprint, and code execution overhead.
Version win8version = new Version(6, 2, 9200, 0); if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version >= win8version) { // its win8 or higher. }
Okay guys, it seems to me that this piece of code has been marked as deprecated by Microsoft itself. I leave a link here so you could read more about it.
In short, it says:
For windows 8 and higher, there always will be the same version number of (6, 2, 9200, 0). And rather than looking for Windows version, go look for the actual feature which existance you are trying to resolve.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With