From 66b29b137477596e8d2014888097d503b03c9f06 Mon Sep 17 00:00:00 2001 From: HolographicHat Date: Sat, 30 Nov 2024 14:13:51 +0800 Subject: [PATCH] static linking --- lib/YaeAchievementLib.vcxproj | 1 + src/Program.cs | 1 - src/Utils.cs | 38 +---------------------------------- 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/lib/YaeAchievementLib.vcxproj b/lib/YaeAchievementLib.vcxproj index 91b7c12..c81ff62 100644 --- a/lib/YaeAchievementLib.vcxproj +++ b/lib/YaeAchievementLib.vcxproj @@ -83,6 +83,7 @@ Speed true stdc11 + MultiThreaded NotSet diff --git a/src/Program.cs b/src/Program.cs index 9819c84..ce85dcc 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -12,7 +12,6 @@ InstallExitHook(); InstallExceptionHook(); CheckSelfIsRunning(); -await CheckVcRuntime(); CheckGenshinIsRunning(); Console.WriteLine(@"----------------------------------------------------"); diff --git a/src/Utils.cs b/src/Utils.cs index df9a014..5f97b4a 100644 --- a/src/Utils.cs +++ b/src/Utils.cs @@ -1,5 +1,4 @@ -using Microsoft.Win32; -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; using System.IO.Pipes; using System.Net; @@ -269,39 +268,4 @@ public static class Utils { th.Start(); return th; } - - public static async Task CheckVcRuntime() { - using var root = Registry.LocalMachine; - using var sub = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")!; - var installed = sub.GetSubKeyNames() - .Select(subKeyName => { - try { - return sub.OpenSubKey(subKeyName); - } catch (Exception) { - return null; - } - }) - .Select(item => item?.GetValue("DisplayName") as string ?? string.Empty) - .Any(name => name.Contains("Microsoft Visual C++ 2022 X64 ") || name.Contains("Microsoft Visual C++ 2015-2022 Redistributable (x64)")); - if (!installed) { - Console.WriteLine(App.VcRuntimeDownload); - var pkgPath = Path.Combine(GlobalVars.DataPath, "vc_redist.x64.exe"); - byte[] bytes; - try { - bytes = await CHttpClient.GetByteArrayAsync("https://aka.ms/vs/17/release/vc_redist.x64.exe"); - } catch (Exception e) when(e is SocketException or TaskCanceledException) { - Console.WriteLine(App.NetworkError, e.Message); - Environment.Exit(-1); - return; - } - await File.WriteAllBytesAsync(pkgPath, bytes); - Console.WriteLine(App.VcRuntimeInstalling); - using var process = new Process(); - process.StartInfo.FileName = pkgPath; - process.StartInfo.Arguments = "/install /passive /norestart"; - process.Start(); - await process.WaitForExitAsync(); - File.Delete(pkgPath); - } - } }