mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-08 11:57:53 +08:00
check integration #468
This commit is contained in:
parent
b62e87f36f
commit
78ec9d31e8
@ -33,6 +33,7 @@ public partial class App : Application
|
||||
// https://docs.microsoft.com/dotnet/core/extensions/configuration
|
||||
// https://docs.microsoft.com/dotnet/core/extensions/logging
|
||||
private static readonly IHost _host = Host.CreateDefaultBuilder()
|
||||
.CheckIntegration()
|
||||
.UseElevated()
|
||||
.UseSingleInstance("BetterGI")
|
||||
.ConfigureServices(
|
||||
|
@ -3,8 +3,10 @@ using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -130,6 +132,21 @@ internal static class RuntimeHelper
|
||||
}
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
}
|
||||
|
||||
public static void CheckIntegration()
|
||||
{
|
||||
if (!Directory.Exists("Assets") || !Directory.Exists("GameTask") || !Directory.Exists("User"))
|
||||
{
|
||||
StringBuilder stringBuilder = new("发现有关键文件缺失,");
|
||||
stringBuilder.Append(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) == Global.StartUpPath
|
||||
? "请不要把主程序exe文件剪切到桌面"
|
||||
: "请重新安装软件");
|
||||
|
||||
MessageBox.Show(stringBuilder.ToString(),
|
||||
"警告", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
Environment.Exit(0xFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class RuntimeExtension
|
||||
@ -145,4 +162,10 @@ internal static class RuntimeExtension
|
||||
RuntimeHelper.CheckSingleInstance(instanceName, callback);
|
||||
return self;
|
||||
}
|
||||
|
||||
public static IHostBuilder CheckIntegration(this IHostBuilder app)
|
||||
{
|
||||
RuntimeHelper.CheckIntegration();
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user