热转印www.yxheatpress.com

公司网站模板http://qiyemoban.software8.co/

常用链接

统计

友情链接

最新评论

C#获取系统版本信息

直接贴代码
public class OSInfoMation  
   {  
       public static string OSBit()  
       {  
           try  
           {  
               ConnectionOptions oConn = new ConnectionOptions();  
               System.Management.ManagementScope managementScope = new System.Management.ManagementScope("\\\\localhost", oConn);  
               System.Management.ObjectQuery objectQuery = new System.Management.ObjectQuery("select AddressWidth from Win32_Processor");  
               ManagementObjectSearcher moSearcher = new ManagementObjectSearcher(managementScope, objectQuery);  
               ManagementObjectCollection moReturnCollection = null;  
               string addressWidth = null;  
               moReturnCollection = moSearcher.Get();  
               foreach (ManagementObject oReturn in moReturnCollection)  
               {  
                   addressWidth = oReturn["AddressWidth"].ToString();  
               }  //www.heatpress123.net
               return addressWidth;  
           }  
           catch  
           {  
               return "获取错误";  
           }  
  
       }  
  
       public static string GetOsVersion()  
       {  
           string osBitString = OSBit();  
             string osVersionString = Environment.OSVersion.ToString();  
           return string.Format(@"系统:{0}。位:{1}", osVersionString, osBitString);  
       }  
   }  
调用:
 
static void Main(string[] args)  
{  
    Console.WriteLine(OSInfoMation.GetOsVersion());  
    Console.ReadLine();  
}  
结果:
系统:Microsoft Windows NT 5.1.2600 Service Pack 3。位:32  
原文;http://www.software8.co/wzjs/cpp/751.html

posted on 2012-11-24 17:10 不听话的 阅读(1221) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理