Skip to content

Commit

Permalink
feat: use windows-registry replace winreg
Browse files Browse the repository at this point in the history
  • Loading branch information
honsunrise committed Aug 14, 2024
1 parent 9d1fd22 commit 620e1f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ hostname = "^0.3"
sysctl = "^0.4"

[target.'cfg(target_os = "windows")'.dependencies]
winreg = "^0.8"
windows-registry = "^0.2"

[dev-dependencies]
criterion = "0.3"
Expand Down
9 changes: 5 additions & 4 deletions src/machine_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ fn machine_id() -> Result<String, SysctlError> {
// https://github.com/rs/xid/blob/efa678f304ab65d6d57eedcb086798381ae22206/hostid_windows.go
#[cfg(target_os = "windows")]
fn machine_id() -> std::io::Result<String> {
let hklm = winreg::RegKey::predef(winreg::enums::HKEY_LOCAL_MACHINE);
let guid: String = hklm
.open_subkey("SOFTWARE\\Microsoft\\Cryptography")?
.get_value("MachineGuid")?;
use windows_registry::*;

let guid = LOCAL_MACHINE
.open("SOFTWARE\\Microsoft\\Cryptography")?
.get_string("MachineGuid")?;
Ok(guid)
}

Expand Down

0 comments on commit 620e1f5

Please sign in to comment.