diff --git a/QuickLook/App.xaml.cs b/QuickLook/App.xaml.cs index 15f3f65..5baa2fb 100644 --- a/QuickLook/App.xaml.cs +++ b/QuickLook/App.xaml.cs @@ -59,6 +59,14 @@ namespace QuickLook private void Application_Startup(object sender, StartupEventArgs e) { + if (ProcessHelper.IsOnWindows10S()) + { + MessageBox.Show("This application does not run on Windows 10 S."); + + Shutdown(); + return; + } + EnsureFirstInstance(); if (!_isFirstInstance) diff --git a/QuickLook/Helpers/ProcessHelper.cs b/QuickLook/Helpers/ProcessHelper.cs index f469877..5e2c344 100644 --- a/QuickLook/Helpers/ProcessHelper.cs +++ b/QuickLook/Helpers/ProcessHelper.cs @@ -16,6 +16,7 @@ // along with this program. If not, see . using System; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using QuickLook.NativeMethods; @@ -46,5 +47,17 @@ namespace QuickLook.Helpers return false; } } + + [SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool IsOnWindows10S() + { + const uint PRODUCT_CLOUD = 0x000000B2; // Windows 10 S + const uint PRODUCT_CLOUDN = 0x000000B3; // Windows 10 S N + + Kernel32.GetProductInfo(Environment.OSVersion.Version.Major, + Environment.OSVersion.Version.Minor, 0, 0, out var osType); + + return osType == PRODUCT_CLOUD || osType == PRODUCT_CLOUDN; + } } } \ No newline at end of file diff --git a/QuickLook/NativeMethods/Kernel32.cs b/QuickLook/NativeMethods/Kernel32.cs index eec903c..f0c8824 100644 --- a/QuickLook/NativeMethods/Kernel32.cs +++ b/QuickLook/NativeMethods/Kernel32.cs @@ -32,5 +32,9 @@ namespace QuickLook.NativeMethods [DllImport("kernel32.dll")] internal static extern IntPtr GetCurrentThreadId(); + + [DllImport("kernel32.dll")] + internal static extern bool GetProductInfo(int dwOSMajorVersion, int dwOSMinorVersion, int dwSpMajorVersion, + int dwSpMinorVersion, out uint pdwReturnedProductType); } } \ No newline at end of file