57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Management;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace NX_Installation
|
|
{
|
|
/// <summary>
|
|
/// Description of WindowsVersion.
|
|
/// </summary>
|
|
class WindowsVersions
|
|
{
|
|
// <summary>
|
|
/// Initialisiert die Werte der Eigenschaften.
|
|
/// </summary>
|
|
static void init()
|
|
{
|
|
using (var mos = new ManagementObjectSearcher("SELECT Caption, Version FROM Win32_OperatingSystem"))
|
|
{
|
|
var attribs = mos.Get().OfType<ManagementObject>();
|
|
caption = attribs.FirstOrDefault().GetPropertyValue("Caption").ToString() ?? "Unknown";
|
|
version = new Version((attribs.FirstOrDefault().GetPropertyValue("Version") ?? "0.0.0.0").ToString());
|
|
}
|
|
}
|
|
|
|
static string caption = null;
|
|
static Version version = null;
|
|
|
|
/// <summary>
|
|
/// Ruft den Namen des Betriebssystems ab.
|
|
/// </summary>
|
|
public static string Caption
|
|
{
|
|
get
|
|
{
|
|
if (caption == null)
|
|
init();
|
|
return caption;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Ruft die Versionsnummer des Betriebssystems ab.
|
|
/// </summary>
|
|
public static Version Version
|
|
{
|
|
get
|
|
{
|
|
if (version == null)
|
|
init();
|
|
return version;
|
|
}
|
|
}
|
|
}
|
|
}
|