获取Windows系统信息

//启动时获取系统信息
            try
            
{
                
this.label1.Text="用户名:"+SystemInformation.UserName;
                
this.label2.Text="计算机名:"+SystemInformation.ComputerName;
                
this.label3.Text="操作系统:"+Environment.OSVersion.Platform;
                
this.label4.Text="版本号:"+Environment.OSVersion.Version;
                
if(SystemInformation.BootMode.ToString()=="Normal")
                    
this.label5.Text="启动方式:正常启动";
                
if(SystemInformation.BootMode.ToString()=="FailSafe")
                    
this.label5.Text="启动方式:安全启动";
                
if(SystemInformation.BootMode.ToString()=="FailSafeWithNetwork")
                    
this.label5.Text="启动方式:通过网络服务启动";
                
if(SystemInformation.Network==true)
                    
this.label6.Text="网络连接:已连接";
                
else
                    
this.label6.Text="网络连接:未连接";
                
this.label7.Text="显示器数量:"+SystemInformation.MonitorCount.ToString();
                
this.label8.Text="显示器分辨率:"+SystemInformation.PrimaryMonitorSize.Width.ToString()+"X"+
                    SystemInformation.PrimaryMonitorSize.Height.ToString();    

               
//获取系统版本
                Process MyProcess=new Process();
                
//设定程序名
                MyProcess.StartInfo.FileName="cmd.exe";
                
//关闭Shell的使用
                MyProcess.StartInfo.UseShellExecute=false;
                
//重定向标准输入
                MyProcess.StartInfo.RedirectStandardInput=true;
                
//重定向标准输出
                MyProcess.StartInfo.RedirectStandardOutput=true;
                
//重定向错误输出
                MyProcess.StartInfo.RedirectStandardError=true;
                
//设置不显示窗口
                MyProcess.StartInfo.CreateNoWindow=true;
                
//执行VER命令(查询系统版本)
                MyProcess.Start();
                MyProcess.StandardInput.WriteLine(
"Ver");
                MyProcess.StandardInput.WriteLine(
"Exit");
                
//从输出流获取命令执行结果
                string StrInfo=MyProcess.StandardOutput.ReadToEnd();
                
this.label9.Text+=StrInfo.Substring(0,StrInfo.IndexOf("Corp.")+5);

            }

            
catch(Exception Err)
            
{
                MessageBox.Show(
"获取系统信息发生错误!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }




            
//获取CPU信息
            try
            
{
                
//使用读取注册表内容的方法获取
                
//使用Microsoft.Win32.Registry类和RegistryKey类
                RegistryKey MyReg=Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\SYSTEM\\CentralProcessor\\0");
                
this.label10.Text=label10.Text+MyReg.GetValue("~MHz").ToString()+"Mhz";
                
this.label11.Text=label11.Text+MyReg.GetValue("Identifier").ToString();
                
this.label12.Text=label12.Text+MyReg.GetValue("ProcessorNameString").ToString();
                
this.label13.Text=label13.Text+MyReg.GetValue("VendorIdentifier").ToString();
            
            }

            
catch(Exception Err)
            
{
               MessageBox.Show(
"获取CUP信息发生错误!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }

下载地址:
https://files.cnblogs.com/mgod/WindowsINI.rar