Check Windows version from C # registry

I have a problem. How to check windows version from registry in C #?

(Windows xp for Windows 8.1)

+4
source share
3 answers

Environment.OSVersion , as others have argued, is the right way.

However, if someone wants to get it through the registry, this can be used -

 using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine .OpenSubKey(@"SOFTWARE\Microsoft\WindowsNT\CurrentVersion")) { var osVersion = key.GetValue("CurrentVersion"); } 

Registry for the HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" version HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" .

In addition, the corresponding comparison with the actual OS from here -

 Operating system Version number ----------------- -------------- Windows 8 6.2 Windows Server 2012 6.2 Windows 7 6.1 Windows Server 2008 R2 6.1 Windows Server 2008 6.0 Windows Vista 6.0 Windows Server 2003 R2 5.2 Windows Server 2003 5.2 Windows XP 64-Bit Edition 5.2 Windows XP 5.1 Windows 2000 5.0 
+5
source

Environment.OSVersion can give you this!

Read the MSDN documentation for the environment class to see all the other things you can get from this class.

+7
source

You do not need to read the registry; System.Environment.OSVersion gives you this information.

+1
source

Source: https://habr.com/ru/post/1497485/


All Articles