feat: VC++可用性检查 (#12445)

* feat: VC++可用性检查

* i18n: too low

terrain
This commit is contained in:
status102
2025-04-25 15:59:51 +08:00
committed by GitHub
parent 2f8840feac
commit fdc76bc5b5
6 changed files with 85 additions and 12 deletions

View File

@@ -59,6 +59,35 @@ namespace MaaWpfGui.Main
public const string CoreLogFilename = "debug/asst.log";
public const string CoreLogBakFilename = "debug/asst.bak.log";
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr LoadLibrary(string dllName);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern bool FreeLibrary(IntPtr hModule);
private bool IsVCppInstalled()
{
IntPtr handle = IntPtr.Zero;
try
{
handle = LoadLibrary("MaaCore.dll");
// 如果句柄非空,说明 DLL 存在且可加载
return handle != IntPtr.Zero;
}
catch (Exception)
{
return false;
}
finally
{
if (handle != IntPtr.Zero)
{
FreeLibrary(handle); // 释放 DLL 句柄
}
}
}
/// <inheritdoc/>
/// <remarks>初始化些啥自己加。</remarks>
protected override void OnStart()
@@ -151,10 +180,33 @@ namespace MaaWpfGui.Main
}
}
base.OnStart();
ConfigurationHelper.Load();
LocalizationHelper.Load();
ETagCache.Load();
if (!IsVCppInstalled())
{
var ret = MessageBox.Show(LocalizationHelper.GetString("VC++NotInstalled"), "MAA", MessageBoxButton.OKCancel);
if (ret == MessageBoxResult.OK)
{
var startInfo = new ProcessStartInfo
{
FileName = "DependencySetup_依赖库安装.bat",
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory, // 设置工作目录
WindowStyle = ProcessWindowStyle.Normal, // 显示窗口让用户看到进度
};
try
{
// 启动进程
Process process = Process.Start(startInfo);
}
catch
{
}
}
Shutdown();
}
if (!HandleMultipleInstances())
{
@@ -162,6 +214,7 @@ namespace MaaWpfGui.Main
return;
}
base.OnStart();
_hasMutex = true;
const string ConfigFlag = "--config";
@@ -316,7 +369,7 @@ namespace MaaWpfGui.Main
Execute.OnUIThread(Application.Current.Shutdown);
}
public static void Shutdown([CallerMemberName]string caller = "")
public static void Shutdown([CallerMemberName] string caller = "")
{
_logger.Information($"Shutdown called by {caller}");
Execute.OnUIThread(Application.Current.Shutdown);

View File

@@ -1016,12 +1016,16 @@ With save file: farm points through crafting (advanced).
<system:String x:Key="ReclamationToolToCraftTip">Support prop name</system:String>
<system:String x:Key="ReclamationToolToCraftPlaceholder">Glow Stick</system:String>
<!-- !Reclamation -->
<!-- SingleInstance -->
<!-- Boot -->
<system:String x:Key="VC++NotInstalled" xml:space="preserve">
Detected that Microsoft Visual C++ Redistributable 2015-2022 (x64) is NOT installed or the version is too low.
Click "OK" to execute the installation script and exit MAA. Click "Cancel" to exit MAA directly.
</system:String>
<system:String x:Key="MultiInstanceUnderSamePath" xml:space="preserve">
Only one instance can be launched under the same path!
If you want to run multiple MAA at the same time, please copy the whole MAA and start under different path with the same adb and different connect address.
</system:String>
<!-- !SingleInstance -->
<!-- !Boot -->
<!-- SimpleEncryptionHelper -->
<system:String x:Key="EncryptionError">Encryption and decryption failed, please reconfigure the relevant settings, otherwise the encrypted content will be stored in plain text in the configuration file.</system:String>
<!-- !SimpleEncryptionHelper -->

View File

@@ -1019,12 +1019,16 @@ C:\\leidian\\LDPlayer9
<system:String x:Key="ReclamationToolToCraftTip">支援道具名</system:String>
<system:String x:Key="ReclamationToolToCraftPlaceholder">ケミカルライト</system:String>
<!-- !Reclamation -->
<!-- SingleInstance -->
<!-- Boot -->
<system:String x:Key="VC++NotInstalled" xml:space="preserve">
Microsoft Visual C++ redistributable 2015-2022 (x64) がインストールされていないか、バージョンが低すぎることが検出されました.
「OK」をクリックするとインストールスクリプトが実行され、MAA が終了します。「キャンセル」をクリックすると MAA が直接終了します。
</system:String>
<system:String x:Key="MultiInstanceUnderSamePath" xml:space="preserve">
同じパスの下で起動できるのは1つのインスタンスのみ
MAA を複数開くには、新しい MAA を他のフォルダにコピーし、異なる MAA、同じ adb、異なるシミュレータアドレスを使用して複数の操作を行うように設定します。
</system:String>
<!-- !SingleInstance -->
<!-- !Boot -->
<!-- SimpleEncryptionHelper -->
<system:String x:Key="EncryptionError">暗号化と復号化に失敗しました。関連設定を再設定してください。そうでないと、暗号化された内容は設定ファイルに平文で保存されます。</system:String>
<!-- !SimpleEncryptionHelper -->

View File

@@ -1017,12 +1017,16 @@ C:\\leidian\\LDPlayer9
<system:String x:Key="ReclamationToolToCraftTip">제작할 도구 이름</system:String>
<system:String x:Key="ReclamationToolToCraftPlaceholder">형광봉</system:String>
<!-- !Reclamation -->
<!-- SingleInstance -->
<!-- Boot -->
<system:String x:Key="VC++NotInstalled" xml:space="preserve">
Microsoft Visual C++ redistributable 2015-2022(x64) 가 설치되지 않았거나 버전이 너무 낮은 것으로 감지되었습니다..
"확인"을 클릭하여 설치 스크립트를 실행하고 MAA를 종료하세요. "취소"를 클릭하여 MAA를 바로 종료하세요.
</system:String>
<system:String x:Key="MultiInstanceUnderSamePath" xml:space="preserve">
동일한 경로에서는 하나의 인스턴스만 실행할 수 있습니다!
여러 개의 MAA를 동시에 실행하려면 MAA 전체 폴더를 복사한 뒤, 같은 adb를 사용하되 연결 주소는 다르게 설정하여 서로 다른 경로에서 실행하세요.
</system:String>
<!-- !SingleInstance -->
<!-- !Boot -->
<!-- SimpleEncryptionHelper -->
<system:String x:Key="EncryptionError">암호화 또는 복호화에 실패했습니다. 관련 설정을 다시 구성해 주세요. 그렇지 않으면 암호화된 내용이 설정 파일에 그대로 저장됩니다.</system:String>
<!-- !SimpleEncryptionHelper -->

View File

@@ -1019,12 +1019,16 @@ C:\\leidian\\LDPlayer9。\n
<system:String x:Key="ReclamationToolToCraftTip">支援道具名称</system:String>
<system:String x:Key="ReclamationToolToCraftPlaceholder">荧光棒</system:String>
<!-- !Reclamation -->
<!-- SingleInstance -->
<!-- Boot -->
<system:String x:Key="VC++NotInstalled" xml:space="preserve">
检测到 Microsoft Visual C++ Redistributable 2015-2022 (x64) 未安装或版本过低,
点击 "确定" 执行安装脚本并退出 MAA, 点击 "取消" 将直接退出.
</system:String>
<system:String x:Key="MultiInstanceUnderSamePath" xml:space="preserve">
同一路径下只能启动一个实例!
如需多开 MAA请复制一份新的 MAA 到其他文件夹下,并设置使用不同的 MAA相同的 adb 和不同的模拟器地址进行多开操作。
</system:String>
<!-- !SingleInstance -->
<!-- !Boot -->
<!-- SimpleEncryptionHelper -->
<system:String x:Key="EncryptionError">加解密失败,请重新配置相关设置,否则加密内容将以明文形式存储在配置文件中。</system:String>
<!-- !SimpleEncryptionHelper -->

View File

@@ -1020,12 +1020,16 @@ C:\\leidian\\LDPlayer9。\n
<system:String x:Key="ReclamationToolToCraftTip">支援道具名稱</system:String>
<system:String x:Key="ReclamationToolToCraftPlaceholder">螢光棒</system:String>
<!-- !Reclamation -->
<!-- SingleInstance -->
<!-- Boot -->
<system:String x:Key="VC++NotInstalled" xml:space="preserve">
偵測到 Microsoft Visual C++ Redistributable 2015-2022 (x64) 未安裝或版本過低,
點擊 "確定" 將執行安裝腳本並退出 MAA, 點擊 "取消" 將直接退出 MAA.
</system:String>
<system:String x:Key="MultiInstanceUnderSamePath" xml:space="preserve">
同一路徑下只能啟動一個實例!
如需多開MAA請複製一份新的MAA到其他資料夾下並設定使用不同的 MAA相同的 adb 和不同的模擬器地址進行多開操作。
</system:String>
<!-- !SingleInstance -->
<!-- !Boot -->
<!-- SimpleEncryptionHelper -->
<system:String x:Key="EncryptionError">加解密失敗,請重新配置相關設置,否則加密內容將以明文形式存儲在配置文件中。</system:String>
<!-- !SimpleEncryptionHelper -->