Trait advapi_Hkey

Source
pub trait advapi_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 31 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 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>, flags: RRF, ) -> 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 features kernel and advapi only.
Expand description

This trait is enabled with the advapi 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 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>, flags: RRF, ) -> SysResult<RegistryValue>

RegGetValue function.

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

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

println!("{val}");
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.

§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"])? {
    println!("{val}");
}
Source

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

Source

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

RegQueryValueEx 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,
)?;

let val = hkey.RegQueryValueEx(Some("Beep"))?;
println!("{val}");
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§