VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > 汇编语言 >
  • C#教程之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();

相关教程