OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::Win::Reg Class Reference

Abstraction of Windows Registry operations. More...

#include <reg.hpp>

Classes

class  Key
 Wrapper class for a Registry key handle. More...
 
class  KeyEnumerator
 Wrapper for Registry subkey enumeration. More...
 

Static Public Member Functions

static std::pair< DWORD, LSTATUS > get_dword (Key &key, PCWSTR name)
 Read a REG_DWORD value from the Windows registry.
 
static std::pair< std::wstring, LSTATUS > get_string (Key &key, PCWSTR name)
 Read a REG_SZ value from the Windows registry.
 
static std::pair< std::string, LSTATUS > get_binary (Key &key, PCWSTR name)
 Read a REG_BINARY value from the Windows registry.
 
static LSTATUS set_dword (Key &key, PCWSTR name, DWORD value)
 Set a DWORD value in the Registry.
 
static LSTATUS set_string (Key &key, PCWSTR name, const std::wstring &value)
 Set a REG_SZ value in the Registy.
 
static LSTATUS set_multi_string (Key &key, PCWSTR name, const std::wstring &value)
 Set a REG_MULTI_SZ value in the Registry.
 
static LSTATUS delete_subkey (const std::wstring &subkey)
 Delete a subkey from the Registry.
 
static LSTATUS delete_value (Key &key, PCWSTR name)
 Delete a value from the Registry.
 

Static Public Attributes

static constexpr PCWSTR gpol_nrpt_subkey = LR"(SOFTWARE\Policies\Microsoft\Windows NT\DNSClient\DnsPolicyConfig)"
 
static constexpr PCWSTR local_nrpt_subkey = LR"(SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DnsPolicyConfig)"
 
static constexpr WCHAR subkey_ipv4_itfs [] = LR"(SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces)"
 
static constexpr WCHAR subkey_ipv6_itfs [] = LR"(SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces)"
 

Detailed Description

Abstraction of Windows Registry operations.

Definition at line 38 of file reg.hpp.

Member Function Documentation

◆ delete_subkey()

static LSTATUS openvpn::Win::Reg::delete_subkey ( const std::wstring &  subkey)
inlinestatic

Delete a subkey from the Registry.

If the subkey contains values or subkeys, these are deleted from the Registry as well.

Parameters
subkeythe subkey to be deleted
Returns
LSTATUS status of the Registry operation

Definition at line 394 of file reg.hpp.

◆ delete_value()

static LSTATUS openvpn::Win::Reg::delete_value ( Key key,
PCWSTR  name 
)
inlinestatic

Delete a value from the Registry.

Parameters
keythe Key where the value is deleted from
namethe name of the value
Returns
LSTATUS status of the Registry operation

Definition at line 406 of file reg.hpp.

◆ get_binary()

static std::pair< std::string, LSTATUS > openvpn::Win::Reg::get_binary ( Key key,
PCWSTR  name 
)
inlinestatic

Read a REG_BINARY value from the Windows registry.

Parameters
keythe key the value is to be read from
namethe name of the REG_BINARY value
Returns
std::pair<std::string, LSTATUS> the binary value and the status code of the registry operations. If the string is empty, the status may indicate an error. Otherwise string::data() and string::size() can be used to access the data from the Registry value.

Definition at line 309 of file reg.hpp.

◆ get_dword()

static std::pair< DWORD, LSTATUS > openvpn::Win::Reg::get_dword ( Key key,
PCWSTR  name 
)
inlinestatic

Read a REG_DWORD value from the Windows registry.

Parameters
keythe key the value is to be read from
namethe name of the REG_DWORD value
Returns
std::pair<std::wstring, LSTATUS> the string and the status code of the registry operations. If the string is empty, the status may indicate an error.

Definition at line 242 of file reg.hpp.

◆ get_string()

static std::pair< std::wstring, LSTATUS > openvpn::Win::Reg::get_string ( Key key,
PCWSTR  name 
)
inlinestatic

Read a REG_SZ value from the Windows registry.

Parameters
keythe key the value is to be read from
namethe name of the REG_SZ value
Returns
std::pair<std::wstring, LSTATUS> the string and the status code of the registry operations. If the string is empty, the status may indicate an error.

Definition at line 272 of file reg.hpp.

◆ set_dword()

static LSTATUS openvpn::Win::Reg::set_dword ( Key key,
PCWSTR  name,
DWORD  value 
)
inlinestatic

Set a DWORD value in the Registry.

Parameters
keythe Key where the value is set in
namethe name of the value
valuethe value itself
Returns
LSTATUS status of the Registry operation

Definition at line 343 of file reg.hpp.

◆ set_multi_string()

static LSTATUS openvpn::Win::Reg::set_multi_string ( Key key,
PCWSTR  name,
const std::wstring &  value 
)
inlinestatic

Set a REG_MULTI_SZ value in the Registry.

Note the this function, unlike the one for REG_SZ values, expects the string value to be set to be a complete MULTI_SZ string, i.e. have two NUL characters at the end, and a NUL character between individual string subvalues.

Parameters
keythe Key where the value is set in
namethe name of the value
valuethe value itself
Returns
LSTATUS status of the Registry operation

Definition at line 378 of file reg.hpp.

◆ set_string()

static LSTATUS openvpn::Win::Reg::set_string ( Key key,
PCWSTR  name,
const std::wstring &  value 
)
inlinestatic

Set a REG_SZ value in the Registy.

Parameters
keythe Key where the value is set in
namethe name of the value
valuethe value itself
Returns
LSTATUS status of the Registry operation

Definition at line 358 of file reg.hpp.

Member Data Documentation

◆ gpol_nrpt_subkey

constexpr PCWSTR openvpn::Win::Reg::gpol_nrpt_subkey = LR"(SOFTWARE\Policies\Microsoft\Windows NT\DNSClient\DnsPolicyConfig)"
staticconstexpr

Registry subkeys where NRPT rules can be found

Definition at line 224 of file reg.hpp.

◆ local_nrpt_subkey

constexpr PCWSTR openvpn::Win::Reg::local_nrpt_subkey = LR"(SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DnsPolicyConfig)"
staticconstexpr

Definition at line 225 of file reg.hpp.

◆ subkey_ipv4_itfs

constexpr WCHAR openvpn::Win::Reg::subkey_ipv4_itfs[] = LR"(SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces)"
staticconstexpr

Registry subkeys where IP configuration for interfaces can be found

Definition at line 230 of file reg.hpp.

◆ subkey_ipv6_itfs

constexpr WCHAR openvpn::Win::Reg::subkey_ipv6_itfs[] = LR"(SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces)"
staticconstexpr

Definition at line 231 of file reg.hpp.


The documentation for this class was generated from the following file: