I am a beginner of C #. This is my reference. I got a small program that obtains information about the current operating system by accessing the registry of the current operating system. It is for reference only.
1 using system;
2 using system. Collections. Generic;
3 using system. componentmodel;
4 using system. Data;
5 using system. drawing;
6 using system. text;
7 using system. Windows. forms;
8 using Microsoft. Win32;
9
10 namespace reg4u
11 {
12 public partial class form1: Form
13 {
14 public form1 ()
15 {
16 initializecomponent ();
17}
18
19 private void button#click (Object sender, eventargs E)
20 {
21 registrykey rk;
22 rk = registry. localmachine. opensubkey ("Software \ Microsoft \ Windows NT \ CurrentVersion ");
23 string S = "current operating system version:" + rk. getvalue ("productname"). tostring ();
24 s = S + "\ r \ n" + rk. getvalue ("csdversion"). tostring ();
25 s = S + "\ r \ n current operating system installation serial number: \ r \ n" + rk. getvalue ("productid"). tostring ();
26 S = S + "\ r \ n Current System Version:" + rk. getvalue ("currentbuildnumber"). tostring ();
27 rk. Close ();
28 textbox1.text = textbox1.text + "\ r \ n" + S;
29}
30
31 private void form1_load (Object sender, eventargs E)
32 {
33 registrykey rk;
34 rk = registry. localmachine. opensubkey ("Software \ Microsoft \ Windows NT \ CurrentVersion ");
35 string S = rk. getvalue ("productname"). tostring ();
36 IF (system. Text. regularexpressions. RegEx. ismatch (S, "Windows 2000 "))
37 {
38 textbox1.text = "your operating system is 2 K. Congratulations! Your current system is suitable for the use of this software! ";
39}
40 rk. Close ();
41}
42}
43}