diff --git a/DerpingDrivers/MainWindow.xaml b/DerpingDrivers/MainWindow.xaml
index ee85074..426e42e 100644
--- a/DerpingDrivers/MainWindow.xaml
+++ b/DerpingDrivers/MainWindow.xaml
@@ -8,11 +8,10 @@
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"
Title="Derping Drivers - Windows driver compatibility detection tool"
- Height="400" Width="700"
+ Height="440" Width="700"
ShowMaxRestoreButton="False"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
- SaveWindowPosition="True"
BorderThickness="0"
GlowBrush="{DynamicResource AccentColorBrush}"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
@@ -28,6 +27,7 @@
+
@@ -40,29 +40,33 @@
+
+
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
-
-
+
diff --git a/DerpingDrivers/MainWindow.xaml.cs b/DerpingDrivers/MainWindow.xaml.cs
index 54cbd67..7c60cca 100644
--- a/DerpingDrivers/MainWindow.xaml.cs
+++ b/DerpingDrivers/MainWindow.xaml.cs
@@ -33,7 +33,12 @@ namespace DerpingDrivers
///
/// Gets Operating System display name.
///
- public string OsVersionName => $"{OsVersionInfo.Name} {OsVersionInfo.Edition}";
+ public string OsVersionName => OsVersionInfo.Name;
+
+ ///
+ /// Gets Operating System edition name.
+ ///
+ public string OsEditionName => string.IsNullOrEmpty(OsVersionInfo.Edition) ? "None" : OsVersionInfo.Edition;
///
/// Gets Operating System build number.
diff --git a/DerpingDrivers/Util/OSVersionInfo.cs b/DerpingDrivers/Util/OSVersionInfo.cs
index 025ef1c..b253b95 100644
--- a/DerpingDrivers/Util/OSVersionInfo.cs
+++ b/DerpingDrivers/Util/OSVersionInfo.cs
@@ -1,6 +1,10 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using System.Runtime.InteropServices;
+using System.Windows;
+using Markdig.Helpers;
using Microsoft.Win32;
// http://www.codeproject.com/Articles/73000/Getting-Operating-System-Version-Info-Even-for-Win
@@ -18,6 +22,16 @@ namespace DerpingDrivers.Util
///
public static class OsVersionInfo
{
+ private static readonly List Windows10ReleaseIds = new OrderedList
+ {
+ "1507",
+ "1607",
+ "1703",
+ "1709",
+ "1803",
+ "1809"
+ };
+
#region SERVICE PACK
///
@@ -39,14 +53,15 @@ namespace DerpingDrivers.Util
#endregion SERVICE PACK
- #region Windows 10 Detection
+ #region Windows 10/Server 2016+ Detection
private static bool IsWindows10()
{
- var productName = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
- "ProductName", "");
- if (productName.StartsWith("Windows 10", StringComparison.OrdinalIgnoreCase)) return true;
- return false;
+ var releaseId = (string) Registry.GetValue(
+ @"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion",
+ "ReleaseId", null);
+
+ return !string.IsNullOrEmpty(releaseId) && Windows10ReleaseIds.Any(id => id.Contains(releaseId));
}
#endregion
@@ -244,8 +259,7 @@ namespace DerpingDrivers.Util
var edition = string.Empty;
var osVersion = Environment.OSVersion;
- var osVersionInfo = new OSVERSIONINFOEX();
- osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
+ var osVersionInfo = new OSVERSIONINFOEX {dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX))};
if (GetVersionEx(ref osVersionInfo))
{
@@ -556,6 +570,10 @@ namespace DerpingDrivers.Util
private static string _name;
+ private static string ReleaseId => (string) Registry.GetValue(
+ @"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion",
+ "ReleaseId", null);
+
///
/// Gets the name of the operating system running on this computer.
///
@@ -673,76 +691,11 @@ namespace DerpingDrivers.Util
break;
case 6:
- switch (minorVersion)
- {
- case 0:
- switch (productType)
- {
- case 1:
- name = "Windows Vista";
- break;
- case 3:
- name = "Windows Server 2008";
- break;
- }
-
- break;
-
- case 1:
- switch (productType)
- {
- case 1:
- name = "Windows 7";
- break;
- case 3:
- name = "Windows Server 2008 R2";
- break;
- }
-
- break;
- case 2:
- switch (productType)
- {
- case 1:
- name = "Windows 8";
- break;
- case 3:
- name = "Windows Server 2012";
- break;
- }
-
- break;
- case 3:
- switch (productType)
- {
- case 1:
- name = "Windows 8.1";
- break;
- case 3:
- name = "Windows Server 2012 R2";
- break;
- }
-
- break;
- }
+ name = ParseVistaThrough8(minorVersion, productType);
break;
case 10:
- switch (minorVersion)
- {
- case 0:
- switch (productType)
- {
- case 1:
- name = "Windows 10";
- break;
- case 3:
- name = "Windows Server 2016";
- break;
- }
-
- break;
- }
+ name = ParseWindows10Version(minorVersion, productType, ReleaseId);
break;
}
@@ -757,6 +710,83 @@ namespace DerpingDrivers.Util
}
}
+ private static string ParseVistaThrough8(int minorVersion, byte productType)
+ {
+ switch (minorVersion)
+ {
+ case 0:
+ switch (productType)
+ {
+ case 1:
+ return "Windows Vista";
+ case 3:
+ return "Windows Server 2008";
+ }
+
+ break;
+
+ case 1:
+ switch (productType)
+ {
+ case 1:
+ return "Windows 7";
+ case 3:
+ return "Windows Server 2008 R2";
+ }
+
+ break;
+ case 2:
+ switch (productType)
+ {
+ case 1:
+ return "Windows 8";
+ case 3:
+ return "Windows Server 2012";
+ }
+
+ break;
+ case 3:
+ switch (productType)
+ {
+ case 1:
+ return "Windows 8.1";
+ case 3:
+ return "Windows Server 2012 R2";
+ }
+
+ break;
+ }
+
+ return string.Empty;
+ }
+
+ private static string ParseWindows10Version(int minorVersion, byte productType, string releaseId)
+ {
+ switch (minorVersion)
+ {
+ case 0:
+ switch (productType)
+ {
+ case 1:
+ return "Windows 10";
+ case 3:
+ switch (releaseId)
+ {
+ case "1607":
+ return "Windows Server 2016";
+ case "1809":
+ return "Windows Server 2019";
+ }
+
+ break;
+ }
+
+ break;
+ }
+
+ return string.Empty;
+ }
+
#endregion NAME
#region PINVOKE
@@ -829,16 +859,16 @@ namespace DerpingDrivers.Util
[StructLayout(LayoutKind.Sequential)]
private struct SYSTEM_INFO
{
- internal _PROCESSOR_INFO_UNION uProcessorInfo;
- public uint dwPageSize;
- public IntPtr lpMinimumApplicationAddress;
- public IntPtr lpMaximumApplicationAddress;
- public IntPtr dwActiveProcessorMask;
- public uint dwNumberOfProcessors;
- public uint dwProcessorType;
- public uint dwAllocationGranularity;
- public ushort dwProcessorLevel;
- public ushort dwProcessorRevision;
+ internal readonly _PROCESSOR_INFO_UNION uProcessorInfo;
+ public readonly uint dwPageSize;
+ public readonly IntPtr lpMinimumApplicationAddress;
+ public readonly IntPtr lpMaximumApplicationAddress;
+ public readonly IntPtr dwActiveProcessorMask;
+ public readonly uint dwNumberOfProcessors;
+ public readonly uint dwProcessorType;
+ public readonly uint dwAllocationGranularity;
+ public readonly ushort dwProcessorLevel;
+ public readonly ushort dwProcessorRevision;
}
#endregion SYSTEM_INFO
@@ -848,9 +878,9 @@ namespace DerpingDrivers.Util
[StructLayout(LayoutKind.Explicit)]
private struct _PROCESSOR_INFO_UNION
{
- [FieldOffset(0)] internal uint dwOemId;
- [FieldOffset(0)] internal ushort wProcessorArchitecture;
- [FieldOffset(2)] internal ushort wReserved;
+ [FieldOffset(0)] internal readonly uint dwOemId;
+ [FieldOffset(0)] internal readonly ushort wProcessorArchitecture;
+ [FieldOffset(2)] internal readonly ushort wReserved;
}
#endregion _PROCESSOR_INFO_UNION