mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-17 03:48:16 +08:00
add vcruntime check
This commit is contained in:
@@ -4,6 +4,8 @@ using YaeAchievement.AppCenterSDK.Models;
|
|||||||
using static YaeAchievement.Utils;
|
using static YaeAchievement.Utils;
|
||||||
|
|
||||||
InstallExitHook();
|
InstallExitHook();
|
||||||
|
|
||||||
|
CheckVcRuntime();
|
||||||
CheckSelfIsRunning();
|
CheckSelfIsRunning();
|
||||||
TryDisableQuickEdit();
|
TryDisableQuickEdit();
|
||||||
InstallExceptionHook();
|
InstallExceptionHook();
|
||||||
|
|||||||
17
src/Utils.cs
17
src/Utils.cs
@@ -243,6 +243,23 @@ public static class Utils {
|
|||||||
return Native.GetConsoleMode(handle, out var mode) && Native.SetConsoleMode(handle, mode&~64);
|
return Native.GetConsoleMode(handle, out var mode) && Native.SetConsoleMode(handle, mode&~64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable CA1416
|
||||||
|
public static void CheckVcRuntime() {
|
||||||
|
using var root = Registry.LocalMachine;
|
||||||
|
using var sub = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")!;
|
||||||
|
var installed = sub.GetSubKeyNames()
|
||||||
|
.Select(subKeyName => sub.OpenSubKey(subKeyName))
|
||||||
|
.Select(item => item?.GetValue("DisplayName") as string ?? string.Empty)
|
||||||
|
.Any(name => name.Contains("Microsoft Visual C++ 2022 X64 "));
|
||||||
|
if (!installed) {
|
||||||
|
Logger.Error("未安装 VcRuntime");
|
||||||
|
Logger.Error("下载地址: https://aka.ms/vs/17/release/vc_redist.x64.exe");
|
||||||
|
Logger.Error("安装完成后,重新打开 YaeAchievement");
|
||||||
|
Environment.Exit(303);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore CA1416
|
||||||
|
|
||||||
public static void CheckGenshinIsRunning() {
|
public static void CheckGenshinIsRunning() {
|
||||||
Process.EnterDebugMode();
|
Process.EnterDebugMode();
|
||||||
foreach (var process in Process.GetProcesses()) {
|
foreach (var process in Process.GetProcesses()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user