fix: win, tray, detect cmdline (#11638)

target x86, run on x64

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-05-05 08:51:25 +08:00
committed by GitHub
parent ca00706a38
commit d56df22838
3 changed files with 60 additions and 1 deletions

View File

@@ -1232,7 +1232,34 @@ pub async fn get_next_nonkeyexchange_msg(
None
}
#[cfg(all(target_os = "windows", not(target_pointer_width = "64")))]
pub fn check_process(arg: &str, same_session_id: bool) -> bool {
let mut path = std::env::current_exe().unwrap_or_default();
if let Ok(linked) = path.read_link() {
path = linked;
}
let Some(filename) = path.file_name() else {
return false;
};
let filename = filename.to_string_lossy().to_string();
match crate::platform::windows::get_pids_with_first_arg_check_session(
&filename,
arg,
same_session_id,
) {
Ok(pids) => {
let self_pid = hbb_common::sysinfo::Pid::from_u32(std::process::id());
pids.into_iter().filter(|pid| *pid != self_pid).count() > 0
}
Err(e) => {
log::error!("Failed to check process with arg: \"{}\", {}", arg, e);
false
}
}
}
#[allow(unused_mut)]
#[cfg(not(all(target_os = "windows", not(target_pointer_width = "64"))))]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn check_process(arg: &str, mut same_uid: bool) -> bool {
#[cfg(target_os = "macos")]