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}