Skip to content
This repository was archived by the owner on Mar 21, 2021. It is now read-only.

Commit 177aa22

Browse files
committed
Prevented the app from running on Windows 10 version 1803 or higher since ths technique used by this app doesn't work on these versions.
1 parent 8139dfb commit 177aa22

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

SetDefaultBrowser/DefaultBrowserChanger.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ static class DefaultBrowserChanger
1616
/// </exception>
1717
public static void Set(Browser browser)
1818
{
19+
// In Windows 10 version 1803, the old control-panel-style Default Programs screen has been replaced with a new one inside the Windows 10 settings app.
20+
// However, the Windows 10 settings app cannot be automated without the user seeing it or interacting with it, so that option is unreliable.
21+
// Fortunately, someone else has written a better alternative to this app (http://kolbi.cz/blog/?p=396).
22+
// So for these reasons, this app won't support this or later versions of Windows.
23+
if (OsInfo.Windows10Version >= 1803)
24+
throw new EnvironmentException($"This app no longer works in this version of Windows.");
25+
1926
// This is needed since the control panel applet can crash if you give it an empty browser name
2027
if (String.IsNullOrWhiteSpace(browser.UniqueApplicationName))
2128
throw new EnvironmentException($"The given browser's unique application name is blank.");

SetDefaultBrowser/OsInfo.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.Win32;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Globalization;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace SetDefaultBrowser
10+
{
11+
static class OsInfo
12+
{
13+
/// <summary>
14+
/// Gets the Windows 10 version number as shown in the "About" screen in the settings app.
15+
/// This value is also known as the Windows 10 "Release ID".
16+
/// </summary>
17+
/// <value>
18+
/// The version number, such as <c>1803</c> or <c>1703</c>, or <c>null</c> if not running on Windows 10.
19+
/// </value>
20+
public static int? Windows10Version
21+
{
22+
get
23+
{
24+
var versionNumberText = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", null);
25+
if (versionNumberText == null)
26+
return null;
27+
28+
return int.Parse(versionNumberText, CultureInfo.InvariantCulture);
29+
}
30+
}
31+
}
32+
}

SetDefaultBrowser/SetDefaultBrowser.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<Compile Include="DesktopProcess.cs" />
6060
<Compile Include="EnvironmentException.cs" />
6161
<Compile Include="ListView.cs" />
62+
<Compile Include="OsInfo.cs" />
6263
<Compile Include="ProcessAccessFlags.cs" />
6364
<Compile Include="ProcessMemoryChunk.cs" />
6465
<Compile Include="Program.cs" />

0 commit comments

Comments
 (0)