Quasar/Client/Core/Information/OSInfo.cs

54 lines
1.4 KiB
C#
Raw Normal View History

2015-02-24 18:21:01 +00:00
using System;
using System.Management;
2015-02-24 18:21:01 +00:00
namespace xClient.Core.Information
{
static public class OSInfo
{
#region BITS
/// <summary>
/// Determines if the current application is 32 or 64-bit.
/// </summary>
static public int Bits
{
get
{
return IntPtr.Size * 8;
}
}
#endregion BITS
#region NAME
static private string _osName;
2015-02-24 18:21:01 +00:00
/// <summary>
/// Gets the name of the operating system running on this computer (including the edition).
2015-02-24 18:21:01 +00:00
/// </summary>
static public string Name
{
get
{
if (_osName != null)
return _osName;
2015-02-24 18:21:01 +00:00
string name = "Uknown OS";
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem"))
2015-02-24 18:21:01 +00:00
{
foreach (ManagementObject os in searcher.Get())
2015-02-24 18:21:01 +00:00
{
name = os["Caption"].ToString();
break;
2015-02-24 18:21:01 +00:00
}
}
if (name.StartsWith("Microsoft"))
name = name.Substring(name.IndexOf(" ", StringComparison.Ordinal) + 1);
2015-02-24 18:21:01 +00:00
_osName = name;
return _osName;
2015-02-24 18:21:01 +00:00
}
}
#endregion NAME
2015-02-24 18:21:01 +00:00
}
}