Я пытаюсь прочитать значение ключа реестра, и оно не работает, даже когда я запускаю приложение от имени администратора:
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);
}
Я получаю сообщение об ошибке:
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)