Skip to content

Commit

Permalink
fix: bump windows-registry and thiserror
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Nov 24, 2024
1 parent a0b2680 commit 87cc7b7
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 55 deletions.
97 changes: 59 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ description = "Auto launch any application or executable at startup. Supports Wi
exclude = ["/test-exe"]

[dependencies]
thiserror = "1"
thiserror = "2"

[target."cfg(not(target_os = \"windows\"))".dependencies]
dirs = "5.0.1"

[target.'cfg(windows)'.dependencies]
windows-registry = "0.2.0"
windows-registry = "0.3.0"
38 changes: 23 additions & 15 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ impl AutoLaunch {
})?;
// this key maybe not found
if let Ok(key) = LOCAL_MACHINE.open(ADMIN_TASK_MANAGER_OVERRIDE_REGKEY) {
key.set_bytes(&self.app_name, &TASK_MANAGER_OVERRIDE_ENABLED_VALUE)
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("failed to set {ADMIN_TASK_MANAGER_OVERRIDE_REGKEY}: {}", e),
)
})?;
key.set_bytes(
&self.app_name,
windows_registry::Type::Bytes,
&TASK_MANAGER_OVERRIDE_ENABLED_VALUE,
)
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("failed to set {ADMIN_TASK_MANAGER_OVERRIDE_REGKEY}: {}", e),
)
})?;
}
} else {
CURRENT_USER
Expand All @@ -78,13 +82,17 @@ impl AutoLaunch {
})?;
// this key maybe not found
if let Ok(key) = CURRENT_USER.open(TASK_MANAGER_OVERRIDE_REGKEY) {
key.set_bytes(&self.app_name, &TASK_MANAGER_OVERRIDE_ENABLED_VALUE)
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("failed to set {TASK_MANAGER_OVERRIDE_REGKEY}: {}", e),
)
})?;
key.set_bytes(
&self.app_name,
windows_registry::Type::Bytes,
&TASK_MANAGER_OVERRIDE_ENABLED_VALUE,
)
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("failed to set {TASK_MANAGER_OVERRIDE_REGKEY}: {}", e),
)
})?;
}
}

Expand Down Expand Up @@ -153,7 +161,7 @@ impl AutoLaunch {
}

fn task_manager_enabled(&self, hk: &Key, path: &str) -> Option<bool> {
let task_manager_override_raw_value = hk.open(path).ok()?.get_bytes(&self.app_name).ok()?;
let task_manager_override_raw_value = hk.open(path).ok()?.get_value(&self.app_name).ok()?;
last_eight_bytes_all_zeros(&task_manager_override_raw_value)
}
}
Expand Down

0 comments on commit 87cc7b7

Please sign in to comment.