C# 判断Windows版本及CPU位数
2010-10-04 22:43
369 查看
class CheckWinVersion { int getOSArchitecture() { string pa = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); return ((String.IsNullOrEmpty(pa) || String.Compare(pa, 0, "x86", 0, 3, true) == 0) ? 32 : 64); } string getOSInfo() { //Get Operating system information. OperatingSystem os = Environment.OSVersion; //Get version information about the os. Version vs = os.Version; //Variable to hold our return value string operatingSystem = ""; if (os.Platform == PlatformID.Win32Windows) { //This is a pre-NT version of Windows switch (vs.Minor) { case 0: operatingSystem = "95"; break; case 10: if (vs.Revision.ToString() == "2222A") operatingSystem = "98SE"; else operatingSystem = "98"; break; case 90: operatingSystem = "Me"; break; default: break; } } else if (os.Platform == PlatformID.Win32NT) { switch (vs.Major) { case 3: operatingSystem = "NT 3.51"; break; case 4: operatingSystem = "NT 4.0"; break; case 5: if (vs.Minor == 0) operatingSystem = "2000"; else operatingSystem = "XP"; break; case 6: if (vs.Minor == 0) operatingSystem = "Vista"; else operatingSystem = "7"; break; default: break; } } //Make sure we actually got something in our OS check //We don't want to just return " Service Pack 2" or " 32-bit" //That information is useless without the OS version. if (operatingSystem != "") { //Got something. Let's prepend "Windows" and get more info. operatingSystem = "Windows " + operatingSystem; //See if there's a service pack installed. if (os.ServicePack != "") { //Append it to the OS name. i.e. "Windows XP Service Pack 3" operatingSystem += " " + os.ServicePack; } //Append the OS architecture. i.e. "Windows XP Service Pack 3 32-bit" operatingSystem += " " + getOSArchitecture().ToString() + "-bit"; } //Return the information we've gathered. return operatingSystem; } }
相关文章推荐
- C# 判断Windows版本及CPU位数
- C# System.Windows.Forms.WebBrowser中判断浏览器内核和版本
- C# 完美实现多语言版本Windows应用程序
- C#更改文件访问权限所有者(适用于各个Windows版本)
- Windows 系统版本判断
- 查看Linux版本、cpu、位数、内核、内存等信息
- c# 安装、注册windows service服务,判断服务是否存在,是否启动
- win32程序判断windows系统(是否为win7或是更高版本)
- Windows 下判断CPU是否64位
- mxnet CPU版本Windows下简单安装(python接口安装)
- 查看linux系统版本,内核,CPU,MEM,位数的相关命令
- x86,I386,i686, x86_64, x64,amd64、Windows Linux AIX下查看CPU位数和操作系统位数、rpm包名
- C#实现注册码 CPU序列号,生成机器码 生成注册码 判断是否注册
- Makefile和automake中判断CPU位数
- C# 判断本机是否安装Excel及多版本安装?获取Excel进程信息和打开Excel应用软件
- Windows下配置Caffe(CPU+GPU版本)
- C#判断整数、小数位数的限定
- 判断Windows版本 和 是否为64Bit
- C# 判断操作系统的位数
- 【转】使用C# 完美实现多语言版本Windows应用程序