Skip to content

Commit

Permalink
feat(self-update): add with_saved_programs_display_version()
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Apr 15, 2024
1 parent 6d35ded commit 0678d7f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cli/self_update/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ fn restore_path(p: Option<RegValue>) {
#[cfg(unix)]
fn restore_path(_: Option<()>) {}

#[cfg(windows)]
pub fn with_saved_programs_display_version(f: &mut dyn FnMut()) {
let root = &RegKey::predef(HKEY_CURRENT_USER);
let key = r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Rustup";
let name = "DisplayVersion";
with_saved_global_state(
|| get_reg_value(root, key, name),
|p| restore_reg_value(root, key, name, p),
f,
)
}

#[cfg(windows)]
fn get_reg_value(root: &RegKey, subkey: &str, name: &str) -> io::Result<Option<RegValue>> {
let subkey = root
Expand Down

0 comments on commit 0678d7f

Please sign in to comment.