Struct registry::RegKey

source ·
pub struct RegKey { /* private fields */ }
Expand description

The safe representation of a Windows registry key.

Implementations§

source§

impl RegKey

source

pub fn open<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn write<P>(&self, file_path: P) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn create<P>(&self, path: P, sec: Security) -> Result<RegKey, Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn delete<P>(&self, path: P, is_recursive: bool) -> Result<(), Error>where P: TryInto<U16CString>, P::Error: Into<Error>,

source

pub fn delete_self(self, is_recursive: bool) -> Result<(), Error>

source

pub fn value<S>(&self, value_name: S) -> Result<Data, Error>where S: TryInto<U16CString>, S::Error: Into<Error>,

source

pub fn delete_value<S>(&self, value_name: S) -> Result<(), Error>where S: TryInto<U16CString>, S::Error: Into<Error>,

source

pub fn set_value<S>(&self, value_name: S, data: &Data) -> Result<(), Error>where S: TryInto<U16CString>, S::Error: Into<Error>,

source

pub fn keys(&self) -> Keys<'_>

Examples found in repository?
examples/appkey.rs (line 22)
16
17
18
19
20
21
22
23
24
25
26
fn walk_keys(key: RegKey, tabstop: i32) {
    for _ in 0..tabstop {
        print!("\t");
    }
    println!("{}", key.to_string());

    for subkey in key.keys() {
        let subkey = subkey.unwrap().open(Security::Read).unwrap();
        walk_keys(subkey, tabstop + 1);
    }
}
More examples
Hide additional 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(())
}
source

pub fn values(&self) -> Values<'_>

source

pub fn open_current_user(sec: Security) -> Result<RegKey, Error>

Trait Implementations§

source§

impl Debug for RegKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for RegKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for RegKey

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for RegKey

§

impl !Send for RegKey

§

impl !Sync for RegKey

§

impl Unpin for RegKey

§

impl UnwindSafe for RegKey

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.