Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Windows name c#

Tags:

c#

I will check my Windows os name (Windows 8 Pro) in c# but it gives an error, what's wrong?

    RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", true);
    string currentKey;
    currentKey = reg.GetValue("ProductName", true).ToString();

    textBox1.Text = currentKey;
like image 866
user2910626 Avatar asked Dec 11 '22 10:12

user2910626


1 Answers

You can use Environment.OSVersion for this.

Edit: Getting the OS name is answered here: Stackoverflow OS Friendly name

like image 77
Measuring Avatar answered Jan 05 '23 16:01

Measuring