public static OperatingSystemInfo GetOperatingSystemInfo(ManagementScope scope) { OperatingSystemInfo operatingSystemInfo = new OperatingSystemInfo(); using (ManagementObject managementObject = WMIUtils.QueryFirst(scope, "Select * from Win32_OperatingSystem")) { string str = managementObject["Version"].ToString(); if (!string.IsNullOrEmpty(str)) { string[] strArray = str.Split(".".ToCharArray()); operatingSystemInfo.VersionString = str; operatingSystemInfo.Version = new OperatingSystemVersion() { Major = Convert.ToInt32(strArray[0]), Minor = Convert.ToInt32(strArray[1]), Build = Convert.ToInt32(managementObject["BuildNumber"]) }; } operatingSystemInfo.ServicePack = string.Format("{0}.{1}.0.0", (object)Convert.ToInt32(managementObject["ServicePackMajorVersion"]).ToString(), (object)Convert.ToInt32(managementObject["ServicePackMinorVersion"]).ToString()); operatingSystemInfo.ProductType = (OperatingSystemProductType)(uint)managementObject["ProductType"]; if (managementObject["OSProductSuite"] != null) { operatingSystemInfo.ProductSuite = (int)(uint)managementObject["OSProductSuite"]; } operatingSystemInfo.Architecture = WMIUtils.GetCPUArchitecture(scope, operatingSystemInfo.Version.Major); } return(operatingSystemInfo); }