How to obtain the software version of the current operating system [For Beginners]

Source: Internet
Author: User

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}
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.