Check .NET Framework version on startup
This commit is contained in:
@@ -130,6 +130,7 @@ System Proxy On: =系统代理已启用:
|
||||
Running: Port {0}=正在运行:端口 {0}
|
||||
Unexpected error, shadowsocks will exit. Please report to=非预期错误,Shadowsocks将退出。请提交此错误到
|
||||
Unsupported operating system, use Windows Vista at least.=不支持的操作系统版本,最低需求为Windows Vista。
|
||||
Unsupported .NET Framework, please update to 4.6.2 or later.=当前 .NET Framework 版本过低,请升级至4.6.2或更新版本。
|
||||
Proxy request failed=代理请求失败
|
||||
Proxy handshake failed=代理握手失败
|
||||
Register hotkey failed=注册热键失败
|
||||
|
||||
@@ -130,6 +130,7 @@ System Proxy On: =系統代理已啟用:
|
||||
Running: Port {0}=正在運行:連接埠號碼 {0}
|
||||
Unexpected error, shadowsocks will exit. Please report to=非預期錯誤,Shadowsocks將退出。請提交此錯誤到
|
||||
Unsupported operating system, use Windows Vista at least.=不支持的作業系統版本,最低需求為Windows Vista。
|
||||
Unsupported .NET Framework, please update to 4.6.2 or later.=當前 .NET Framework 版本過低,最低需求為4.6.2。
|
||||
Proxy request failed=代理請求失敗
|
||||
Proxy handshake failed=代理握手失敗
|
||||
Register hotkey failed=註冊捷徑鍵失敗
|
||||
|
||||
@@ -31,6 +31,14 @@ namespace Shadowsocks
|
||||
return;
|
||||
}
|
||||
|
||||
// Check .NET Framework version
|
||||
if (!Utils.IsSupportedRuntimeVersion())
|
||||
{
|
||||
MessageBox.Show(I18N.GetString("Unsupported .NET Framework, please update to 4.6.2 or later."),
|
||||
"Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.ReleaseMemory(true);
|
||||
using (Mutex mutex = new Mutex(false, $"Global\\Shadowsocks_{Application.StartupPath.GetHashCode()}"))
|
||||
{
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace Shadowsocks.Util
|
||||
return new BandwidthScaleInfo(f, unit, scale);
|
||||
}
|
||||
|
||||
public static RegistryKey OpenRegKey( string name, bool writable, RegistryHive hive = RegistryHive.CurrentUser )
|
||||
public static RegistryKey OpenRegKey(string name, bool writable, RegistryHive hive = RegistryHive.CurrentUser)
|
||||
{
|
||||
// we are building x86 binary for both x86 and x64, which will
|
||||
// cause problem when opening registry key
|
||||
@@ -233,7 +233,8 @@ namespace Shadowsocks.Util
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsWinVistaOrHigher() {
|
||||
public static bool IsWinVistaOrHigher()
|
||||
{
|
||||
return Environment.OSVersion.Version.Major > 5;
|
||||
}
|
||||
|
||||
@@ -241,5 +242,35 @@ namespace Shadowsocks.Util
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool SetProcessWorkingSetSize(IntPtr process,
|
||||
UIntPtr minimumWorkingSetSize, UIntPtr maximumWorkingSetSize);
|
||||
|
||||
|
||||
// See: https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx
|
||||
public static bool IsSupportedRuntimeVersion()
|
||||
{
|
||||
/*
|
||||
* +-----------------------------------------------------------------+----------------------------+
|
||||
* | Version | Value of the Release DWORD |
|
||||
* +-----------------------------------------------------------------+----------------------------+
|
||||
* | .NET Framework 4.6.2 installed on Windows 10 Anniversary Update | 394802 |
|
||||
* | .NET Framework 4.6.2 installed on all other Windows OS versions | 394806 |
|
||||
* +-----------------------------------------------------------------+----------------------------+
|
||||
*/
|
||||
const int minSupportedRelease = 394802;
|
||||
|
||||
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
|
||||
using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
|
||||
{
|
||||
if (ndpKey?.GetValue("Release") != null)
|
||||
{
|
||||
var releaseKey = (int)ndpKey.GetValue("Release");
|
||||
|
||||
if (releaseKey >= minSupportedRelease)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user