Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
RegistryKey Class Referencefinal

Public Member Functions

 RegistryKey ()
 
 RegistryKey (HKEY parent, const std::wstring &name)
 
 RegistryKey (const RegistryKey &parent, const std::wstring &name)
 
 ~RegistryKey ()
 
 RegistryKey (const RegistryKey &)=delete
 
RegistryKeyoperator= (const RegistryKey &)=delete
 
void SetValue (const wchar_t *subKey, const std::wstring &value)
 

Private Attributes

HKEY mKeyHandle {}
 

Detailed Description


Audacity: A Digital Audio Editor

SchemeRegistrar.cpp

Dmitry Vedenko

Definition at line 40 of file win/SchemeRegistrar.cpp.

Constructor & Destructor Documentation

◆ RegistryKey() [1/4]

RegistryKey::RegistryKey ( )
inline

Definition at line 43 of file win/SchemeRegistrar.cpp.

44 {
45 auto result = RegOpenCurrentUser(KEY_ALL_ACCESS, &mKeyHandle);
46
47 if (result != ERROR_SUCCESS)
48 {
49 wxLogDebug(
50 "Failed to create registry key: %s", wxSysErrorMsgStr(result));
51 throw std::exception("Failed to create registry key");
52 }
53 }

References mKeyHandle.

◆ RegistryKey() [2/4]

RegistryKey::RegistryKey ( HKEY  parent,
const std::wstring &  name 
)
inline

Definition at line 55 of file win/SchemeRegistrar.cpp.

56 {
57 auto result =
58 RegOpenKeyExW(parent, name.c_str(), 0, KEY_ALL_ACCESS, &mKeyHandle);
59
60 if (result == ERROR_FILE_NOT_FOUND)
61 result = RegCreateKeyW(parent, name.c_str(), &mKeyHandle);
62
63 if (result != ERROR_SUCCESS)
64 {
65 wxLogDebug("Failed to open registry key: %s", wxSysErrorMsgStr(result));
66 throw std::exception("Failed to open registry key");
67 }
68 }
wxString name
Definition: TagsEditor.cpp:166

References mKeyHandle, and name.

◆ RegistryKey() [3/4]

RegistryKey::RegistryKey ( const RegistryKey parent,
const std::wstring &  name 
)
inline

Definition at line 70 of file win/SchemeRegistrar.cpp.

71 : RegistryKey(parent.mKeyHandle, name)
72 {
73 }

◆ ~RegistryKey()

RegistryKey::~RegistryKey ( )
inline

Definition at line 75 of file win/SchemeRegistrar.cpp.

76 {
77 RegCloseKey(mKeyHandle);
78 }

References mKeyHandle.

◆ RegistryKey() [4/4]

RegistryKey::RegistryKey ( const RegistryKey )
delete

Member Function Documentation

◆ operator=()

RegistryKey & RegistryKey::operator= ( const RegistryKey )
delete

◆ SetValue()

void RegistryKey::SetValue ( const wchar_t *  subKey,
const std::wstring &  value 
)
inline

Definition at line 83 of file win/SchemeRegistrar.cpp.

84 {
85 auto result = RegSetValueExW(
86 mKeyHandle, subKey, 0, REG_SZ,
87 reinterpret_cast<const BYTE*>(value.c_str()),
88 (value.size() + 1) * sizeof(wchar_t));
89
90 if (result != ERROR_SUCCESS)
91 {
92 wxLogDebug(
93 "Failed to set value to a registry key: %s", wxSysErrorMsgStr(result));
94 throw std::exception("Failed to set value to a registry key");
95 }
96 }

References mKeyHandle.

Member Data Documentation

◆ mKeyHandle

HKEY RegistryKey::mKeyHandle {}
private

Definition at line 99 of file win/SchemeRegistrar.cpp.

Referenced by RegistryKey(), SetValue(), and ~RegistryKey().


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