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
yes, you my friend caused with your complaints that SO block me from asking questions, and I really do not feel that your arguments were justified especially because I try really hard to find answer before asking one… so I asked my friend to ask second question on my behalf… I saw that you gave answer regarding antivirus, but that is not the cause of my problems
Hi Toma,
First off all, I posted the link so somebody who sees this question also can see the one on stackoverflow.
Second, you won’t get banned of stackoverflow because of one question…
I think jethrogb is on the right track through.