Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect Windows 8 Operating system using C# 4.0?

Tags:

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.

like image 744
Rajesh Subramanian Avatar asked Nov 29 '12 06:11

Rajesh Subramanian


People also ask

How do I find my operating system Windows 8?

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.

How do I check C system?

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.

Does Windows run on C?

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.


1 Answers

Version win8version = new Version(6, 2, 9200, 0);  if (Environment.OSVersion.Platform == PlatformID.Win32NT &&     Environment.OSVersion.Version >= win8version) {     // its win8 or higher. } 

Update for windows 8.1 and 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.

like image 139
AgentFire Avatar answered Sep 27 '22 02:09

AgentFire