Hi, I'm complete newbie to Rust, so please be patient
I'm trying to read registry key value and it fails even when I run app as an Administrator. My code:
extern crate winreg;
use winreg::enums::{HKEY_LOCAL_MACHINE, KEY_READ};
fn main() {
let hklm = winreg::RegKey::predef(HKEY_LOCAL_MACHINE);
let subkey = hklm
.open_subkey_with_flags(
r#"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"#,
KEY_READ,
)
.expect("Failed to open subkey");
let u_uac_status: String = subkey.get_value("EnableLUA").expect("Failed to read");
let mut r_uac_status: String = String::new();
if u_uac_status == "1" {
r_uac_status = String::from("Enable");
} else {
r_uac_status = String::from("Disable");
}
println!("UAC status: {}", r_uac_status);
}
The error:
thread 'main' panicked at 'Failed to read: Os { code: 222, kind: Other, message: "The file type being saved or retrieved has been blocked." }', libcore\result.rs:1009:5
note: Run with RUST_BACKTRACE=1
for a backtrace.
error: process didn't exit successfully (exit code: 101)
I tried to set RUST_BACKTRACE = 1 then cargo run, but it pops the same.
Thanks