Crate windows_registry

Source
Expand description

§Windows registry

The windows-registry crate provides simple, safe, and efficient access to the Windows registry.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-registry]
version = "0.5"

Read and write registry keys and values as needed:

use windows_registry::*;

fn main() -> Result<()> {
    let key = CURRENT_USER.create("software\\windows-rs")?;

    key.set_u32("number", 123)?;
    key.set_string("name", "Rust")?;

    println!("{}", key.get_u32("number")?);
    println!("{}", key.get_string("name")?);

    Ok(())
}

Use the options() method for even more control:

use windows_registry::*;

fn main() -> Result<()> {
    let tx = Transaction::new()?;

    let key = CURRENT_USER
        .options()
        .read()
        .write()
        .create()
        .transaction(&tx)
        .open("software\\windows-rs")?;

    key.set_u32("name", 123)?;

    tx.commit()?;

    Ok(())
}

Structs§

HSTRING
An (HSTRING) is a reference-counted and immutable UTF-16 string type.
Key
A registry key.
KeyIterator
An iterator of registry key names.
OpenOptions
Options and flags used to configure how a registry key is opened.
Transaction
A transaction object.
Value
A registry value.
ValueIterator
An iterator of registry values.

Enums§

Type
The possible types that a registry value could have.

Constants§

CLASSES_ROOT
The predefined HKEY_CLASSES_ROOT registry key.
CURRENT_CONFIG
The predefined HKEY_CURRENT_CONFIG registry key.
CURRENT_USER
The predefined HKEY_CURRENT_USER registry key.
LOCAL_MACHINE
The predefined HKEY_LOCAL_MACHINE registry key.
USERS
The predefined HKEY_USERS registry key.

Type Aliases§

Result
A specialized Result type that provides Windows error information.