Trait winsafe::prelude::kernel_Hkey

source ·
pub trait kernel_Hkey: Handle {
    const CLASSES_ROOT: HKEY = _;
    const CURRENT_USER: HKEY = _;
    const LOCAL_MACHINE: HKEY = _;
    const USERS: HKEY = _;
    const PERFORMANCE_DATA: HKEY = _;
    const CURRENT_CONFIG: HKEY = _;
    const DYN_DATA: HKEY = _;
    const CURRENT_USER_LOCAL_SETTINGS: HKEY = _;
    const PERFORMANCE_TEXT: HKEY = _;
    const PERFORMANCE_NLSTEXT: HKEY = _;
Show 33 methods // Provided methods fn RegConnectRegistry( machine_name: Option<&str>, predef_hkey: &HKEY ) -> SysResult<RegCloseKeyGuard> { ... } fn RegCopyTree(&self, sub_key: Option<&str>, dest: &HKEY) -> SysResult<()> { ... } fn RegCreateKeyEx( &self, sub_key: &str, class: Option<&str>, options: REG_OPTION, access_rights: KEY, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>> ) -> SysResult<(RegCloseKeyGuard, REG_DISPOSITION)> { ... } fn RegCreateKeyTransacted( &self, sub_key: &str, class: Option<&str>, options: REG_OPTION, access_rights: KEY, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, htransaction: &HTRANSACTION ) -> SysResult<(RegCloseKeyGuard, REG_DISPOSITION)> { ... } fn RegDeleteKey(&self, sub_key: &str) -> SysResult<()> { ... } fn RegDeleteKeyEx(&self, sub_key: &str, platform_view: KEY) -> SysResult<()> { ... } fn RegDeleteKeyTransacted( &self, sub_key: &str, access_rights: KEY, htransaction: &HTRANSACTION ) -> SysResult<()> { ... } fn RegDeleteTree(&self, sub_key: Option<&str>) -> SysResult<()> { ... } fn RegDeleteValue(&self, value_name: Option<&str>) -> SysResult<()> { ... } fn RegDisablePredefinedCache() -> SysResult<()> { ... } fn RegDisablePredefinedCacheEx() -> SysResult<()> { ... } fn RegDisableReflectionKey(&self) -> SysResult<()> { ... } fn RegEnableReflectionKey(&self) -> SysResult<()> { ... } fn RegEnumKeyEx( &self ) -> SysResult<impl Iterator<Item = SysResult<String>> + '_> { ... } fn RegEnumValue( &self ) -> SysResult<impl Iterator<Item = SysResult<(String, REG)>> + '_> { ... } fn RegFlushKey(&self) -> SysResult<()> { ... } fn RegGetValue( &self, sub_key: Option<&str>, value_name: Option<&str> ) -> SysResult<RegistryValue> { ... } fn RegLoadKey( &self, sub_key: Option<&str>, file_path: &str ) -> SysResult<()> { ... } fn RegOpenCurrentUser(access_rights: KEY) -> SysResult<RegCloseKeyGuard> { ... } fn RegOpenKeyEx( &self, sub_key: Option<&str>, options: REG_OPTION, access_rights: KEY ) -> SysResult<RegCloseKeyGuard> { ... } fn RegOpenKeyTransacted( &self, sub_key: &str, options: REG_OPTION, access_rights: KEY, htransaction: &HTRANSACTION ) -> SysResult<RegCloseKeyGuard> { ... } fn RegQueryInfoKey( &self, class: Option<&mut WString>, num_sub_keys: Option<&mut u32>, max_sub_key_name_len: Option<&mut u32>, max_class_len: Option<&mut u32>, num_values: Option<&mut u32>, max_value_name_len: Option<&mut u32>, max_value_len: Option<&mut u32>, security_descr_len: Option<&mut u32>, last_write_time: Option<&mut FILETIME> ) -> SysResult<()> { ... } fn RegQueryMultipleValues( &self, value_names: &[impl AsRef<str>] ) -> SysResult<Vec<RegistryValue>> { ... } fn RegQueryReflectionKey(&self) -> SysResult<bool> { ... } fn RegQueryValueEx( &self, value_name: Option<&str> ) -> SysResult<RegistryValue> { ... } fn RegRenameKey( &self, sub_key_name: &str, new_key_name: &str ) -> SysResult<()> { ... } fn RegReplaceKey( &self, sub_key: Option<&str>, new_src_file: &str, old_file_backup: &str ) -> SysResult<()> { ... } fn RegRestoreKey( &self, file_path: &str, flags: REG_RESTORE ) -> SysResult<()> { ... } fn RegSaveKey( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>> ) -> SysResult<()> { ... } fn RegSaveKeyEx( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, flags: REG_SAVE ) -> SysResult<()> { ... } fn RegSetKeyValue( &self, sub_key: Option<&str>, value_name: Option<&str>, data: RegistryValue ) -> SysResult<()> { ... } fn RegSetValueEx( &self, value_name: Option<&str>, data: RegistryValue ) -> SysResult<()> { ... } fn RegUnLoadKey(&self, sub_key: Option<&str>) -> SysResult<()> { ... }
}
Available on crate feature kernel only.
Expand description

This trait is enabled with the kernel feature, and provides methods for HKEY.

Prefer importing this trait through the prelude:

use winsafe::prelude::*;

Provided Associated Constants§

source

const CLASSES_ROOT: HKEY = _

Predefined registry key, always open.

source

const CURRENT_USER: HKEY = _

Predefined registry key, always open.

source

const LOCAL_MACHINE: HKEY = _

Predefined registry key, always open.

source

const USERS: HKEY = _

Predefined registry key, always open.

source

const PERFORMANCE_DATA: HKEY = _

Predefined registry key, always open.

source

const CURRENT_CONFIG: HKEY = _

Predefined registry key, always open.

source

const DYN_DATA: HKEY = _

Predefined registry key, always open.

source

const CURRENT_USER_LOCAL_SETTINGS: HKEY = _

Predefined registry key, always open.

source

const PERFORMANCE_TEXT: HKEY = _

Predefined registry key, always open.

source

const PERFORMANCE_NLSTEXT: HKEY = _

Predefined registry key, always open.

Provided Methods§

source

fn RegConnectRegistry( machine_name: Option<&str>, predef_hkey: &HKEY ) -> SysResult<RegCloseKeyGuard>

RegConnectRegistry function.

§Panics

Panics if predef_key is different from:

source

fn RegCopyTree(&self, sub_key: Option<&str>, dest: &HKEY) -> SysResult<()>

RegCopyTree function.

source

fn RegCreateKeyEx( &self, sub_key: &str, class: Option<&str>, options: REG_OPTION, access_rights: KEY, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>> ) -> SysResult<(RegCloseKeyGuard, REG_DISPOSITION)>

RegCreateKeyEx function.

source

fn RegCreateKeyTransacted( &self, sub_key: &str, class: Option<&str>, options: REG_OPTION, access_rights: KEY, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, htransaction: &HTRANSACTION ) -> SysResult<(RegCloseKeyGuard, REG_DISPOSITION)>

source

fn RegDeleteKey(&self, sub_key: &str) -> SysResult<()>

RegDeleteKey function.

source

fn RegDeleteKeyEx(&self, sub_key: &str, platform_view: KEY) -> SysResult<()>

RegDeleteKeyEx function.

§Panics

Panics if platform_view is different from co::KEY::WOW64_32KEY and co::KEY::WOW64_64KEY.

source

fn RegDeleteKeyTransacted( &self, sub_key: &str, access_rights: KEY, htransaction: &HTRANSACTION ) -> SysResult<()>

source

fn RegDeleteTree(&self, sub_key: Option<&str>) -> SysResult<()>

RegDeleteTree function.

source

fn RegDeleteValue(&self, value_name: Option<&str>) -> SysResult<()>

RegDeleteValue function.

source

fn RegDisablePredefinedCache() -> SysResult<()>

source

fn RegDisablePredefinedCacheEx() -> SysResult<()>

source

fn RegDisableReflectionKey(&self) -> SysResult<()>

source

fn RegEnableReflectionKey(&self) -> SysResult<()>

source

fn RegEnumKeyEx( &self ) -> SysResult<impl Iterator<Item = SysResult<String>> + '_>

Returns an iterator over the names of the keys, which calls RegEnumKeyEx repeatedly.

§Examples
use winsafe::{self as w, prelude::*, co};

let hkey = w::HKEY::CURRENT_USER.RegOpenKeyEx(
    Some("Control Panel"),
    co::REG_OPTION::default(),
    co::KEY::READ,
)?;

for key_name in hkey.RegEnumKeyEx()? {
    let key_name = key_name?;
    println!("{}", key_name);
}
source

fn RegEnumValue( &self ) -> SysResult<impl Iterator<Item = SysResult<(String, REG)>> + '_>

Returns an iterator of the names and types of the values, which calls RegEnumValue repeatedly.

§Examples
use winsafe::{self as w, prelude::*, co};

let hkey = w::HKEY::CURRENT_USER.RegOpenKeyEx(
    Some("Control Panel\\Appearance"),
    co::REG_OPTION::default(),
    co::KEY::READ,
)?;

for value_and_type in hkey.RegEnumValue()? {
    let (value, reg_type) = value_and_type?;
    println!("{}, {}", value, reg_type);
}

// Collecting into a Vec
let values_and_types: Vec<(String, co::REG)> =
    hkey.RegEnumValue()?
        .collect::<w::SysResult<Vec<_>>>()?;
source

fn RegFlushKey(&self) -> SysResult<()>

RegFlushKey function.

source

fn RegGetValue( &self, sub_key: Option<&str>, value_name: Option<&str> ) -> SysResult<RegistryValue>

RegGetValue function.

Note that this method validates some race conditions, returning co::ERROR::TRANSACTION_REQUEST_NOT_VALID and co::ERROR::INVALID_DATA.

§Examples
use winsafe::{self as w, prelude::*};

let val = w::HKEY::CURRENT_USER.RegGetValue(
    Some("Control Panel\\Mouse"),
    Some("Beep"),
)?;

match val {
    w::RegistryValue::Dword(n) => println!("Number u32: {}", n),
    w::RegistryValue::Qword(n) => println!("Number u64: {}", n),
    w::RegistryValue::Sz(s) => println!("String: {}", s),
    w::RegistryValue::ExpandSz(s) => {
        println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?);
    },
    w::RegistryValue::MultiSz(strs) => {
       println!("Multi string:");
       for s in strs.iter() {
           print!("[{}] ", s);
       }
       println!("");
    },
    w::RegistryValue::Binary(bin) => {
        println!("Binary:");
        for b in bin.iter() {
            print!("{:02x} ", b);
        }
        println!("");
    },
    w::RegistryValue::None => println!("No value"),
}
source

fn RegLoadKey(&self, sub_key: Option<&str>, file_path: &str) -> SysResult<()>

RegLoadKey function.

source

fn RegOpenCurrentUser(access_rights: KEY) -> SysResult<RegCloseKeyGuard>

source

fn RegOpenKeyEx( &self, sub_key: Option<&str>, options: REG_OPTION, access_rights: KEY ) -> SysResult<RegCloseKeyGuard>

RegOpenKeyEx function.

§Examples
use winsafe::{self as w, prelude::*, co};

let hkey = w::HKEY::CURRENT_USER.RegOpenKeyEx(
    Some("Control Panel\\Mouse"),
    co::REG_OPTION::default(),
    co::KEY::READ,
)?;
source

fn RegOpenKeyTransacted( &self, sub_key: &str, options: REG_OPTION, access_rights: KEY, htransaction: &HTRANSACTION ) -> SysResult<RegCloseKeyGuard>

source

fn RegQueryInfoKey( &self, class: Option<&mut WString>, num_sub_keys: Option<&mut u32>, max_sub_key_name_len: Option<&mut u32>, max_class_len: Option<&mut u32>, num_values: Option<&mut u32>, max_value_name_len: Option<&mut u32>, max_value_len: Option<&mut u32>, security_descr_len: Option<&mut u32>, last_write_time: Option<&mut FILETIME> ) -> SysResult<()>

RegQueryInfoKey function.

source

fn RegQueryMultipleValues( &self, value_names: &[impl AsRef<str>] ) -> SysResult<Vec<RegistryValue>>

RegQueryMultipleValues function.

This method is a multi-value version of HKEY::RegQueryValueEx.

Note that this method validates some race conditions, returning co::ERROR::TRANSACTION_REQUEST_NOT_VALID.

§Examples
use winsafe::{self as w, prelude::*, co};

let hkey = w::HKEY::CURRENT_USER.RegOpenKeyEx(
    Some("Control Panel\\Desktop"),
    co::REG_OPTION::default(),
    co::KEY::READ,
)?;

for val in hkey.RegQueryMultipleValues(&["DpiScalingVer", "WallPaper"])? {
    match val {
        w::RegistryValue::Dword(n) => println!("Number u32: {}", n),
        w::RegistryValue::Qword(n) => println!("Number u64: {}", n),
        w::RegistryValue::Sz(s) => println!("String: {}", s),
        w::RegistryValue::ExpandSz(s) => {
            println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?);
        },
        w::RegistryValue::MultiSz(strs) => {
           println!("Multi string:");
           for s in strs.iter() {
               print!("[{}] ", s);
           }
           println!("");
        },
        w::RegistryValue::Binary(bin) => {
            println!("Binary:");
            for b in bin.iter() {
                print!("{:02x} ", b);
            }
            println!("");
        },
        w::RegistryValue::None => println!("No value"),
    }
}
source

fn RegQueryReflectionKey(&self) -> SysResult<bool>

source

fn RegQueryValueEx(&self, value_name: Option<&str>) -> SysResult<RegistryValue>

RegQueryValueEx function.

This method is a single-value version of HKEY::RegQueryMultipleValues.

Note that this method validates some race conditions, returning co::ERROR::TRANSACTION_REQUEST_NOT_VALID and co::ERROR::INVALID_DATA.

§Examples
use winsafe::{self as w, prelude::*, co};

let hkey = w::HKEY::CURRENT_USER.RegOpenKeyEx(
    Some("Control Panel\\Mouse"),
    co::REG_OPTION::default(),
    co::KEY::READ,
)?;

let val = hkey.RegQueryValueEx(Some("Beep"))?;

match val {
    w::RegistryValue::Dword(n) => println!("Number u32: {}", n),
    w::RegistryValue::Qword(n) => println!("Number u64: {}", n),
    w::RegistryValue::Sz(s) => println!("String: {}", s),
    w::RegistryValue::ExpandSz(s) => {
        println!("Env string: {}", w::ExpandEnvironmentStrings(&s)?);
    },
    w::RegistryValue::MultiSz(strs) => {
       println!("Multi string:");
       for s in strs.iter() {
           print!("[{}] ", s);
       }
       println!("");
    },
    w::RegistryValue::Binary(bin) => {
        println!("Binary:");
        for b in bin.iter() {
            print!("{:02x} ", b);
        }
        println!("");
    },
    w::RegistryValue::None => println!("No value"),
}
source

fn RegRenameKey(&self, sub_key_name: &str, new_key_name: &str) -> SysResult<()>

RegRenameKey function.

source

fn RegReplaceKey( &self, sub_key: Option<&str>, new_src_file: &str, old_file_backup: &str ) -> SysResult<()>

RegReplaceKey function.

source

fn RegRestoreKey(&self, file_path: &str, flags: REG_RESTORE) -> SysResult<()>

RegRestoreKey function.

source

fn RegSaveKey( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>> ) -> SysResult<()>

RegSaveKey function.

source

fn RegSaveKeyEx( &self, dest_file_path: &str, security_attributes: Option<&SECURITY_ATTRIBUTES<'_>>, flags: REG_SAVE ) -> SysResult<()>

RegSaveKeyEx function.

source

fn RegSetKeyValue( &self, sub_key: Option<&str>, value_name: Option<&str>, data: RegistryValue ) -> SysResult<()>

RegSetKeyValue function.

If the value doesn’t exist, if will be created. If new type is different from current type, new type will take over.

§Examples
use winsafe::{self as w, prelude::*};

w::HKEY::CURRENT_USER.RegSetKeyValue(
    Some("Software\\My Company"),
    Some("Color"),
    w::RegistryValue::Sz("blue".to_owned()),
)?;
source

fn RegSetValueEx( &self, value_name: Option<&str>, data: RegistryValue ) -> SysResult<()>

RegSetValueEx function.

If the value doesn’t exist, if will be created. If new type is different from current type, new type will prevail.

§Examples
use winsafe::{self as w, prelude::*, co};

let hkey = w::HKEY::CURRENT_USER.RegOpenKeyEx(
    Some("Console\\Git Bash"),
    co::REG_OPTION::default(),
    co::KEY::ALL_ACCESS,
)?;

hkey.RegSetValueEx(
    Some("Color"),
    w::RegistryValue::Sz("blue".to_owned()),
)?;
source

fn RegUnLoadKey(&self, sub_key: Option<&str>) -> SysResult<()>

RegUnLoadKey function.

Object Safety§

This trait is not object safe.

Implementors§