refact: win idd, x86 on x64 (#7796)

* refact: win idd, x86 on x64

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* comments

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* typo

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* refact: win idd, check if x64 and deviceinstaller64 exits

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* refact: win idd

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* refact: win idd, add logs

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-04-23 17:00:41 +08:00
committed by GitHub
parent 1b4a41b522
commit b407893db5
10 changed files with 275 additions and 78 deletions

View File

@@ -29,6 +29,7 @@ use std::{
time::{Duration, Instant},
};
use wallpaper;
use winapi::um::sysinfoapi::{GetNativeSystemInfo, SYSTEM_INFO};
use winapi::{
ctypes::c_void,
shared::{minwindef::*, ntdef::NULL, windef::*, winerror::*},
@@ -1302,7 +1303,7 @@ fn get_uninstall(kill_self: bool) -> String {
if exist \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{app_name} Tray.lnk\" del /f /q \"%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{app_name} Tray.lnk\"
",
before_uninstall=get_before_uninstall(kill_self),
uninstall_amyuni_idd=get_uninstall_amyuni_idd(&path),
uninstall_amyuni_idd=get_uninstall_amyuni_idd(),
app_name = crate::get_app_name(),
)
}
@@ -2369,7 +2370,7 @@ impl Drop for WallPaperRemover {
}
}
fn get_uninstall_amyuni_idd(path: &str) -> String {
fn get_uninstall_amyuni_idd() -> String {
match std::env::current_exe() {
Ok(path) => format!("\"{}\" --uninstall-amyuni-idd", path.to_str().unwrap_or("")),
Err(e) => {
@@ -2390,3 +2391,13 @@ pub fn is_service_running(service_name: &str) -> bool {
is_service_running_w(service_name.as_ptr() as _)
}
}
pub fn is_x64() -> bool {
const PROCESSOR_ARCHITECTURE_AMD64: u16 = 9;
let mut sys_info = SYSTEM_INFO::default();
unsafe {
GetNativeSystemInfo(&mut sys_info as _);
}
unsafe { sys_info.u.s().wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 }
}