pub struct RegKey { /* private fields */ }
Expand description
The safe representation of a Windows registry key.
Implementations§
source§impl RegKey
impl RegKey
pub fn open<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
pub fn write<P>(&self, file_path: P) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
pub fn create<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
pub fn delete<P>(&self, path: P, is_recursive: bool) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,
pub fn delete_self(self, is_recursive: bool) -> Result<(), Error>
pub fn value<S>(&self, value_name: S) -> Result<Data, Error>where S: TryInto<U16CString>, S::Error: Into<Error>,
pub fn delete_value<S>(&self, value_name: S) -> Result<(), Error>where S: TryInto<U16CString>, S::Error: Into<Error>,
pub fn set_value<S>(&self, value_name: S, data: &Data) -> Result<(), Error>where S: TryInto<U16CString>, S::Error: Into<Error>,
sourcepub fn keys(&self) -> Keys<'_> ⓘ
pub fn keys(&self) -> Keys<'_> ⓘ
Examples found in repository?
More examples
examples/private-hive.rs (line 31)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
fn main() -> Result<(), std::io::Error> {
let mut token = std::ptr::null_mut();
let r = unsafe { OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &mut token) };
if r == 0 {
return Err(std::io::Error::last_os_error());
}
set_privilege(token, SE_RESTORE_NAME)?;
set_privilege(token, SE_BACKUP_NAME)?;
let hive_key = Hive::load_file(
r"C:\Users\Default\NTUSER.DAT",
Security::Read | Security::Write,
)
.unwrap();
let keys: Vec<_> = hive_key.keys().map(|k| k.unwrap().to_string()).collect();
println!("{:?}", keys);
Ok(())
}