From 3c2a5efc2c1bd772a421cc426e97a7de43e1e4af Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 20 Aug 2026 14:03:48 +0800 Subject: [PATCH 1/3] fix: relax `windows-registry` versions for lower MSRV --- Cargo.lock | 1 - Cargo.toml | 3 +-- src/windows.rs | 17 ++++++++--------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8958446..df294ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,7 +20,6 @@ dependencies = [ "smappservice-rs", "thiserror", "windows-registry", - "windows-result", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d78b26c..d0d590c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,7 @@ os_info = { version = "3", default-features = false } dirs = "^6" [target.'cfg(windows)'.dependencies] -windows-registry = "^0.6" -windows-result = "^0.4" +windows-registry = ">=0.5, <=0.6" [target.'cfg(target_os = "macos")'.dependencies] smappservice-rs = "0.1" diff --git a/src/windows.rs b/src/windows.rs index 39ccb55..e86309e 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,7 +1,6 @@ use crate::{AutoLaunch, Result, WindowsEnableMode}; use std::io; use windows_registry::{Key, CURRENT_USER, LOCAL_MACHINE}; -use windows_result::HRESULT; const AL_REGKEY: &str = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; const TASK_MANAGER_OVERRIDE_REGKEY: &str = @@ -9,8 +8,8 @@ const TASK_MANAGER_OVERRIDE_REGKEY: &str = const TASK_MANAGER_OVERRIDE_ENABLED_VALUE: [u8; 12] = [ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ]; -const E_ACCESSDENIED: HRESULT = HRESULT::from_win32(0x80070005_u32); -const E_FILENOTFOUND: HRESULT = HRESULT::from_win32(0x80070002_u32); +const E_ACCESSDENIED: i32 = 0x80070005_u32 as _; +const E_FILENOTFOUND: i32 = 0x80070002_u32 as _; /// Windows implement impl AutoLaunch { @@ -48,7 +47,7 @@ impl AutoLaunch { WindowsEnableMode::Dynamic => self .enable_as_admin() .or_else(|e| { - if e.code() == E_ACCESSDENIED { + if e.code().0 == E_ACCESSDENIED { self.enable_as_current_user() } else { Err(e) @@ -87,7 +86,7 @@ impl AutoLaunch { windows_registry::Type::Bytes, &TASK_MANAGER_OVERRIDE_ENABLED_VALUE, )?, - Err(error) if error.code() == E_FILENOTFOUND => { + Err(error) if error.code().0 == E_FILENOTFOUND => { return Ok(()); } Err(error) => { @@ -106,7 +105,7 @@ impl AutoLaunch { pub fn disable(&self) -> Result<()> { // try to delete both admin and current user registry values if let Err(error) = self.disable_as_admin() { - if error.code() == E_ACCESSDENIED { + if error.code().0 == E_ACCESSDENIED { match self.enable_mode { // Fail if our enable mode is system but we don't have the access WindowsEnableMode::System => return Err(std::io::Error::from(error).into()), @@ -138,7 +137,7 @@ impl AutoLaunch { .and_then(|key| key.remove_value(&self.app_name)) { Ok(_) => Ok(()), - Err(error) if error.code() == E_FILENOTFOUND => Ok(()), + Err(error) if error.code().0 == E_FILENOTFOUND => Ok(()), Err(error) => Err(error), } } @@ -161,7 +160,7 @@ impl AutoLaunch { .and_then(|key| key.get_string(&self.app_name)) { Ok(_) => true, - Err(error) if error.code() == E_FILENOTFOUND => false, + Err(error) if error.code().0 == E_FILENOTFOUND => false, Err(error) => { return Err(error.into()); } @@ -175,7 +174,7 @@ impl AutoLaunch { .and_then(|key| key.get_value(&self.app_name)) { Ok(value) => last_eight_bytes_all_zeros(&value).unwrap_or(true), - Err(error) if error.code() == E_FILENOTFOUND => true, + Err(error) if error.code().0 == E_FILENOTFOUND => true, Err(error) => { return Err(error.into()); } From f856adda1a3e7ae3715dc7d9443d5783e0271519 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 20 Aug 2026 14:10:42 +0800 Subject: [PATCH 2/3] rename to `E_FILE_NOT_FOUND` --- src/windows.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index e86309e..b6553a5 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -9,7 +9,7 @@ const TASK_MANAGER_OVERRIDE_ENABLED_VALUE: [u8; 12] = [ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ]; const E_ACCESSDENIED: i32 = 0x80070005_u32 as _; -const E_FILENOTFOUND: i32 = 0x80070002_u32 as _; +const E_FILE_NOT_FOUND: i32 = 0x80070002_u32 as _; /// Windows implement impl AutoLaunch { @@ -86,7 +86,7 @@ impl AutoLaunch { windows_registry::Type::Bytes, &TASK_MANAGER_OVERRIDE_ENABLED_VALUE, )?, - Err(error) if error.code().0 == E_FILENOTFOUND => { + Err(error) if error.code().0 == E_FILE_NOT_FOUND => { return Ok(()); } Err(error) => { @@ -137,7 +137,7 @@ impl AutoLaunch { .and_then(|key| key.remove_value(&self.app_name)) { Ok(_) => Ok(()), - Err(error) if error.code().0 == E_FILENOTFOUND => Ok(()), + Err(error) if error.code().0 == E_FILE_NOT_FOUND => Ok(()), Err(error) => Err(error), } } @@ -160,7 +160,7 @@ impl AutoLaunch { .and_then(|key| key.get_string(&self.app_name)) { Ok(_) => true, - Err(error) if error.code().0 == E_FILENOTFOUND => false, + Err(error) if error.code().0 == E_FILE_NOT_FOUND => false, Err(error) => { return Err(error.into()); } @@ -174,7 +174,7 @@ impl AutoLaunch { .and_then(|key| key.get_value(&self.app_name)) { Ok(value) => last_eight_bytes_all_zeros(&value).unwrap_or(true), - Err(error) if error.code().0 == E_FILENOTFOUND => true, + Err(error) if error.code().0 == E_FILE_NOT_FOUND => true, Err(error) => { return Err(error.into()); } From d48759bc10308b5521a12954d1b7ee0c0ad3c60b Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 20 Aug 2026 14:19:23 +0800 Subject: [PATCH 3/3] rename to `ERROR_FILE_NOT_FOUND` --- src/windows.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index b6553a5..00a65b1 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -9,7 +9,7 @@ const TASK_MANAGER_OVERRIDE_ENABLED_VALUE: [u8; 12] = [ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ]; const E_ACCESSDENIED: i32 = 0x80070005_u32 as _; -const E_FILE_NOT_FOUND: i32 = 0x80070002_u32 as _; +const ERROR_FILE_NOT_FOUND: i32 = 0x80070002_u32 as _; /// Windows implement impl AutoLaunch { @@ -86,7 +86,7 @@ impl AutoLaunch { windows_registry::Type::Bytes, &TASK_MANAGER_OVERRIDE_ENABLED_VALUE, )?, - Err(error) if error.code().0 == E_FILE_NOT_FOUND => { + Err(error) if error.code().0 == ERROR_FILE_NOT_FOUND => { return Ok(()); } Err(error) => { @@ -137,7 +137,7 @@ impl AutoLaunch { .and_then(|key| key.remove_value(&self.app_name)) { Ok(_) => Ok(()), - Err(error) if error.code().0 == E_FILE_NOT_FOUND => Ok(()), + Err(error) if error.code().0 == ERROR_FILE_NOT_FOUND => Ok(()), Err(error) => Err(error), } } @@ -160,7 +160,7 @@ impl AutoLaunch { .and_then(|key| key.get_string(&self.app_name)) { Ok(_) => true, - Err(error) if error.code().0 == E_FILE_NOT_FOUND => false, + Err(error) if error.code().0 == ERROR_FILE_NOT_FOUND => false, Err(error) => { return Err(error.into()); } @@ -174,7 +174,7 @@ impl AutoLaunch { .and_then(|key| key.get_value(&self.app_name)) { Ok(value) => last_eight_bytes_all_zeros(&value).unwrap_or(true), - Err(error) if error.code().0 == E_FILE_NOT_FOUND => true, + Err(error) if error.code().0 == ERROR_FILE_NOT_FOUND => true, Err(error) => { return Err(error.into()); }