C #: How to Obtain the software version of the current operating system

Source: Internet
Author: User
Tags tostring

I am a C # beginners, this is my reference to some information, I made a small program to obtain information about the current operating system by accessing the registry of the current operating system for informational purposes only.

1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using Microsoft.Win32;
9
10namespace reg4u
11{
public partial class Form1:form
13 {
Public Form1 ()
15 {
InitializeComponent ();
17}
18
private void Button1_Click (object sender, EventArgs e)
20 {
RegistryKey RK;
RK = Registry.LocalMachine.OpenSubKey ("Software\\microsoft\\windows nt\\currentversion");
s= string "Current operating system version:" +rk. GetValue ("ProductName"). ToString ();
s = s + "\ r \ n" +rk. GetValue ("CSDVersion"). ToString ();
s = s + "\ r \ n Current operating system installation serial number: \ r \ n" + RK. GetValue ("ProductId"). ToString ();
num s = s + "\ r \ n Current system version number:" + RK. GetValue ("Currentbuildnumber"). ToString ();
The RK. Close ();
TextBox1.Text = textbox1.text+ "\ r \ n" +s;
29}
30
to private void Form1_Load (object sender, EventArgs e)
32 {
RegistryKey RK;
The RK = Registry.LocalMachine.OpenSubKey ("Software\\microsoft\\windows nt\\currentversion");
The string s = rk. GetValue ("ProductName"). ToString ();
(System.Text.RegularExpressions.Regex.IsMatch (S, "Windows 2000"))
37 {
TextBox1.Text = "Your operating system is 2K, congratulations, your current system is suitable for the use of the software!" ";
39}
The RK. Close ();
41}
42}
43}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.