Clean up Windows version comparison

fixes 1b8158f4c
This commit is contained in:
YoshiRulz 2023-02-08 22:24:22 +10:00
parent 6ea9e37e33
commit eafb1fdcf5
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 14 additions and 18 deletions

View File

@ -247,25 +247,21 @@ namespace BizHawk.Client.EmuHawk
_ = SetDllDirectory(dllDir);
}
//skip privilege
bool skipPrivilegesCheck = false;
var oldVersions = new[] { OSTC.WindowsVersion.XP, OSTC.WindowsVersion.Vista, OSTC.WindowsVersion._7, OSTC.WindowsVersion._8, OSTC.WindowsVersion._8_1 };
if(OSTC.HostWindowsVersion.HasValue)
if(oldVersions.Contains(OSTC.HostWindowsVersion.Value.Version))
skipPrivilegesCheck = true;
if (EmuHawkUtil.CLRHostHasElevatedPrivileges && !skipPrivilegesCheck)
if (OSTC.HostWindowsVersion is null || OSTC.HostWindowsVersion.Value.Version >= OSTC.WindowsVersion._10) // "windows isn't capable of being useful for non-administrators until windows 10" --zeromus
{
using MsgBox dialog = new(
title: "This EmuHawk is privileged",
message: $"EmuHawk detected it {(OSTC.IsUnixHost ? "is running as root (Superuser)" : "has Administrator privileges")}.\n"
+ "This is a bad idea.",
boxIcon: MessageBoxIcon.Warning);
dialog.ShowDialog();
}
else
{
Util.DebugWriteLine("running as unprivileged user");
if (EmuHawkUtil.CLRHostHasElevatedPrivileges)
{
using MsgBox dialog = new(
title: "This EmuHawk is privileged",
message: $"EmuHawk detected it {(OSTC.IsUnixHost ? "is running as root (Superuser)" : "has Administrator privileges")}.\n"
+ "This is a bad idea.",
boxIcon: MessageBoxIcon.Warning);
dialog.ShowDialog();
}
else
{
Util.DebugWriteLine("running as unprivileged user");
}
}
var exitCode = 0;