From 4103b1524905ae9a80c6f7435bd3a1bb680f39da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com>
Date: Fri, 5 Nov 2021 21:56:51 +0800
Subject: [PATCH] =?UTF-8?q?null=E6=A3=80=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub.UI/Program.cs | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/FastGithub.UI/Program.cs b/FastGithub.UI/Program.cs
index fd0276b..09ebcd1 100644
--- a/FastGithub.UI/Program.cs
+++ b/FastGithub.UI/Program.cs
@@ -21,7 +21,7 @@ namespace FastGithub.UI
}
StartFastGithub();
- SetWebBrowserVersion(9000);
+ SetWebBrowserVersion();
var app = new Application();
app.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
@@ -51,12 +51,18 @@ namespace FastGithub.UI
///
/// 设置浏览器版本
///
- ///
- private static void SetWebBrowserVersion(int version)
+ private static void SetWebBrowserVersion()
{
- var registry = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
- var key = $"{Process.GetCurrentProcess().ProcessName}.exe";
- registry.SetValue(key, version, RegistryValueKind.DWord);
+ const string subKey = @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
+ var registryKey = Registry.CurrentUser.OpenSubKey(subKey, true);
+ if (registryKey == null)
+ {
+ registryKey = Registry.CurrentUser.CreateSubKey(subKey);
+ }
+ var name = $"{Process.GetCurrentProcess().ProcessName}.exe";
+ using var webBrowser = new System.Windows.Forms.WebBrowser();
+ var value = int.Parse($"{webBrowser.Version.Major}000");
+ registryKey.SetValue(name, value, RegistryValueKind.DWord);
}
///