diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/winreg/examples/load_app_key.rs | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/winreg/examples/load_app_key.rs')
-rw-r--r-- | third_party/rust/winreg/examples/load_app_key.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/third_party/rust/winreg/examples/load_app_key.rs b/third_party/rust/winreg/examples/load_app_key.rs new file mode 100644 index 0000000000..2340c82b59 --- /dev/null +++ b/third_party/rust/winreg/examples/load_app_key.rs @@ -0,0 +1,26 @@ +// Copyright 2021, Igor Shaula +// Licensed under the MIT License <LICENSE or +// http://opensource.org/licenses/MIT>. This file +// may not be copied, modified, or distributed +// except according to those terms. +extern crate winreg; +use std::io; +use winreg::enums::*; +use winreg::RegKey; + +fn main() -> io::Result<()> { + { + // put this in a block so app_key_1 gets out of scope and doesn't prevent us + // from loading the key again later + let app_key_1 = RegKey::load_app_key("myhive.dat", true)?; + app_key_1.set_value("answer", &42u32)?; + } + let answer: u32 = { + // NOTE: on Windows 7 this fails with ERROR_ALREADY_EXISTS + let app_key_2 = + RegKey::load_app_key_with_flags("myhive.dat", KEY_READ, REG_PROCESS_APPKEY)?; + app_key_2.get_value("answer")? + }; + println!("The Answer is {}", answer); + Ok(()) +} |