diff --git a/src/windows.rs b/src/windows.rs index a92db31..96f5712 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -11,8 +11,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: u32 = 0x80070005; -const E_FILENOTFOUND: u32 = 0x80070002; +const E_ACCESSDENIED: HRESULT = HRESULT::from_win32(0x80070005_u32); +const E_FILENOTFOUND: HRESULT = HRESULT::from_win32(0x80070002_u32); /// Windows implement impl AutoLaunch { @@ -41,7 +41,7 @@ impl AutoLaunch { pub fn enable(&self) -> Result<()> { self.enable_as_admin() .or_else(|e| { - if e.code() == windows_result::HRESULT(E_ACCESSDENIED as i32) { + if e.code() == E_ACCESSDENIED { self.enable_as_current_user() } else { Err(e) @@ -92,7 +92,7 @@ impl AutoLaunch { pub fn disable(&self) -> Result<()> { self.disable_as_admin() .or_else(|e| { - if e.code() == HRESULT(E_ACCESSDENIED as i32) { + if e.code() == E_ACCESSDENIED { self.disable_as_current_user() } else { Err(e) @@ -118,9 +118,7 @@ impl AutoLaunch { pub fn is_enabled(&self) -> Result { let res = match self.is_enabled_as_admin() { Ok(false) => self.is_enabled_as_current_user(), - Err(e) if e.code() == HRESULT(E_ACCESSDENIED as i32) => { - self.is_enabled_as_current_user() - } + Err(e) if e.code() == E_ACCESSDENIED => self.is_enabled_as_current_user(), Ok(enabled) => Ok(enabled), Err(e) => Err(e), } @@ -134,7 +132,7 @@ impl AutoLaunch { .get_string(&self.app_name) .map(|_| true) .or_else(|e| { - if e.code() == HRESULT(E_FILENOTFOUND as i32) { + if e.code() == E_FILENOTFOUND { Ok(false) } else { Err(e) @@ -152,7 +150,7 @@ impl AutoLaunch { .get_string(&self.app_name) .map(|_| true) .or_else(|e| { - if e.code() == HRESULT(E_FILENOTFOUND as i32) { + if e.code() == E_FILENOTFOUND { Ok(false) } else { Err(e)