2015-02-24 18:21:01 +00:00
|
|
|
|
using System;
|
2015-04-01 13:39:32 +00:00
|
|
|
|
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
|
2015-04-01 13:39:32 +00:00
|
|
|
|
static private string _osName;
|
2015-02-24 18:21:01 +00:00
|
|
|
|
/// <summary>
|
2015-04-01 13:39:32 +00:00
|
|
|
|
/// 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
|
|
|
|
|
{
|
2015-04-01 13:39:32 +00:00
|
|
|
|
if (_osName != null)
|
|
|
|
|
return _osName;
|
2015-02-24 18:21:01 +00:00
|
|
|
|
|
2015-04-01 13:39:32 +00:00
|
|
|
|
string name = "Uknown OS";
|
|
|
|
|
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem"))
|
2015-02-24 18:21:01 +00:00
|
|
|
|
{
|
2015-04-01 13:39:32 +00:00
|
|
|
|
foreach (ManagementObject os in searcher.Get())
|
2015-02-24 18:21:01 +00:00
|
|
|
|
{
|
2015-04-01 13:39:32 +00:00
|
|
|
|
name = os["Caption"].ToString();
|
|
|
|
|
break;
|
2015-02-24 18:21:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-01 13:39:32 +00:00
|
|
|
|
if (name.StartsWith("Microsoft"))
|
|
|
|
|
name = name.Substring(name.IndexOf(" ", StringComparison.Ordinal) + 1);
|
2015-02-24 18:21:01 +00:00
|
|
|
|
|
2015-04-01 13:39:32 +00:00
|
|
|
|
_osName = name;
|
|
|
|
|
return _osName;
|
2015-02-24 18:21:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-01 13:39:32 +00:00
|
|
|
|
#endregion NAME
|
2015-02-24 18:21:01 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|