Skip to main content

Module registry

Module registry 

Source
Expand description

Windows Registry operations.

This module provides ergonomic access to the Windows Registry with automatic handle management and type-safe value operations.

§Examples

§Basic Usage

use windows_erg::registry::{Hive, RegistryKey};

// Open a key
let key = RegistryKey::open(
    Hive::LocalMachine,
    r"SOFTWARE\Microsoft\Windows\CurrentVersion"
)?;

// Read a string value
let program_files: String = key.get_value("ProgramFilesDir")?;

// Create a new key and write values
let key = RegistryKey::create(Hive::CurrentUser, r"Software\MyApp")?;
key.set_value("Version", "1.0.0")?;
key.set_value("Count", 42u32)?;

// Enumerate subkeys
for subkey in key.subkeys()? {
    println!("Subkey: {}", subkey);
}

§Convenience Functions

use windows_erg::registry::{self, Hive};

// Quick read/write without opening a key
let version = registry::read_string(
    Hive::LocalMachine,
    r"SOFTWARE\Microsoft\Windows NT\CurrentVersion",
    "ProductName"
)?;

registry::write_u32(Hive::CurrentUser, r"Software\MyApp", "Count", 42)?;

§Advanced Key Opening

use windows_erg::registry::{Hive, RegistryKey};

// Open with WOW64 view and specific access
let key = RegistryKey::builder()
    .hive(Hive::LocalMachine)
    .path(r"SOFTWARE\MyApp")
    .write()
    .wow64_32()
    .open()?;

Structs§

RegistryKey
A Windows Registry key with automatic handle management.
RegistryKeyBuilder
Builder for opening registry keys with specific options.

Enums§

Access
Access rights for registry keys.
Hive
Registry hive identifiers.

Traits§

RegistryValue
Trait for types that can be read from and written to the registry.

Functions§

apply_permissions
Apply a permission edit plan to a registry key.
read_binary
Read binary data from the registry.
read_bool
Read a boolean value from the registry (stored as DWORD).
read_multi_string
Read a multi-string value from the registry.
read_security_descriptor
Read a registry key security descriptor.
read_string
Read a string value from the registry without opening a key.
read_u32
Read a DWORD (u32) value from the registry.
read_u64
Read a QWORD (u64) value from the registry.
write_binary
Write binary data to the registry.
write_bool
Write a boolean value to the registry (stored as DWORD).
write_multi_string
Write a multi-string value to the registry.
write_security_descriptor
Write a registry key security descriptor.
write_string
Write a string value to the registry without opening a key.
write_u32
Write a DWORD (u32) value to the registry.
write_u64
Write a QWORD (u64) value to the registry.