♻️ msix环境下将dll移动到文档目录

#206
This commit is contained in:
BTMuli
2026-01-18 17:28:44 +08:00
parent 1bd2fa34d3
commit c1ce2def26
7 changed files with 56 additions and 14 deletions

View File

@@ -186,3 +186,35 @@ pub fn launch_game(path: String, ticket: String) -> Result<(), String> {
Err("This command is only supported on Windows".into())
}
}
#[tauri::command]
pub fn is_msix() -> bool {
#[cfg(not(windows))]
{
false
}
#[cfg(windows)]
{
use std::ptr;
use widestring::U16CStr;
use windows_sys::Win32::Foundation::ERROR_INSUFFICIENT_BUFFER;
use windows_sys::Win32::Storage::Packaging::Appx::GetCurrentPackageFullName;
unsafe {
let mut length: u32 = 0;
let result = GetCurrentPackageFullName(&mut length, ptr::null_mut());
if result != ERROR_INSUFFICIENT_BUFFER {
println!("Not running in MSIX package. Error code: {}", result);
return false;
}
let mut buffer = vec![0u16; length as usize];
let result = GetCurrentPackageFullName(&mut length, buffer.as_mut_ptr());
if result != 0 {
println!("Failed to retrieve package full name. Error code: {}", result);
return false;
}
let pkg_name = U16CStr::from_ptr_str(buffer.as_ptr());
println!("MSIX Package Full Name: {}", pkg_name.to_string_lossy());
true
}
}
}

View File

@@ -13,8 +13,8 @@ mod yae;
use crate::client::create_mhy_client;
use crate::commands::{
create_window, execute_js, get_dir_size, hide_main_window, init_app, is_in_admin, launch_game,
quit_app, read_text_scale,
create_window, execute_js, get_dir_size, hide_main_window, init_app, is_in_admin, is_msix,
launch_game, quit_app, read_text_scale,
};
use tauri::{Emitter, Manager, Window, WindowEvent, generate_context, generate_handler};
@@ -109,6 +109,7 @@ pub fn run() {
quit_app,
read_text_scale,
launch_game,
is_msix,
#[cfg(target_os = "windows")]
yae::call_yae_dll,
#[cfg(target_os = "windows")]

View File

@@ -1,5 +1,5 @@
//! Yae 相关处理
//! @since Beta v0.9.1
//! @since Beta v0.9.2
#![cfg(target_os = "windows")]
pub mod inject;
@@ -11,7 +11,7 @@ use pt_ac::parse_achi_list;
use pt_store::parse_store_list;
use serde_json::Value;
use std::collections::HashMap;
use std::fs::{self, File};
use std::fs::File;
use std::io::{self, Read, Write};
use std::os::windows::io::{FromRawHandle, RawHandle};
use std::sync::Arc;
@@ -73,8 +73,12 @@ pub fn call_yae_dll(
game_path: String,
uid: String,
ticket: Option<String>,
is_msix: bool,
) -> Result<(), String> {
let dll_path = app_handle.path().app_config_dir().unwrap().join("YaeAchievementLib.dll");
let mut dll_path = app_handle.path().app_config_dir().unwrap().join("YaeAchievementLib.dll");
if (is_msix) {
dll_path = app_handle.path().document_dir().unwrap().join("TeyvatGuide\\YaeAchievementLib.dll");
}
dbg!(&dll_path);
// 0. 创建 YaeAchievementPipe 的 命名管道,获取句柄
dbg!("开始启动 YaeAchievementPipe 命名管道");