Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)aaa
published in(发表于) 2013/12/6 10:26:07
C#:如何获取当前操作系统的软件版本_.net资料_编程技术

C#:如何获取当前操作系统的软件版本_.net资料_编程技术-数科优化网

我是一个C#的初学者,这是我参考一些资料,自己弄的一个通过访问当前操作系统的注册表来获取当前操作系统相关信息的小程序,仅供参考。


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{
12 public partial class Form1 : Form
13 {
14 public Form1()
15 {
16 InitializeComponent();
17 }
18
19 private void button1_Click(object sender, EventArgs e)
20 {
21 RegistryKey rk;
22 rk = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion");
23 string s= "当前操作系统版本:"+rk.GetValue("ProductName").ToString();
24 s = s +"\r\n"+rk.GetValue("CSDVersion").ToString() ;
25 s = s + "\r\n当前操作系统安装序列号:\r\n" + rk.GetValue("ProductId").ToString();
26 s = s + "\r\n当前系统版本号:" + 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 = "您的操作系统是2K,恭喜您,你的当前系统适合本软件的使用!";
39 }
40 rk.Close();
41 }
42 }
43}






If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759