Retrieving MachineGuid on Windows in Rust
AFAIK Generating UUID and Xid needs the MachineGuid, so I looked around how to obtain it.
And this is the solution, which I'm not sure if it will work on every Windows machine. 😅
main.rs
use winreg::RegKey;
use winreg::enums::*;
use std::io;
fn main() -> io::Result<()> {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let cur_ver = hklm.open_subkey("SOFTWARE\\Microsoft\\Cryptography")?;
let guid: String = cur_ver.get_value("MachineGuid")?;
println!("MachineGuid = {}", guid);
Ok(())
}
Cargo.toml
[package]
name = "mach_guid"
version = "0.1.0"
authors = ["veer6"]
edition = "2018"
[dependencies]
winreg = "0.6"