Determine which operating system your program is running on with C#

Another tutorial from my developing for windows 7 series. How to check what OS the program is running on.

Layout of the form I'm using
OperatingSystem SystemInfo = Environment.OSVersion;
        public Form1()
        {
            InitializeComponent();
            label2.Text = SystemInfo.VersionString;
            label1.Text = OSV();
        }
        private string OSV()
        {
            if (SystemInfo.Platform == System.PlatformID.Win32NT)
            {
                if (SystemInfo.Version.Major == 5)
                    return "XP";
                else if (SystemInfo.Version.Major == 6)
                {
                    if (SystemInfo.Version.Minor == 1)
                        return "Win 7";                    
                    return "Vista";
                }
            }
            return "";
        }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: