7zip/CPP/Windows/Registry.h

97 lines
2.9 KiB
C
Raw Normal View History

2021-12-27 01:00:00 +01:00
// Windows/Registry.h
2023-06-21 02:00:00 +02:00
#ifndef ZIP7_INC_WINDOWS_REGISTRY_H
#define ZIP7_INC_WINDOWS_REGISTRY_H
2021-12-27 01:00:00 +01:00
#include "../Common/MyBuffer.h"
#include "../Common/MyString.h"
namespace NWindows {
namespace NRegistry {
LONG SetValue(HKEY parentKey, LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value);
class CKey
{
HKEY _object;
2024-11-29 01:00:00 +01:00
LONG QueryValueEx(LPCTSTR lpValueName, LPDWORD lpType,
LPBYTE lpData, LPDWORD lpcbData)
{
return RegQueryValueEx(_object, lpValueName, NULL, lpType, lpData, lpcbData);
}
2021-12-27 01:00:00 +01:00
public:
CKey(): _object(NULL) {}
~CKey() { Close(); }
operator HKEY() const { return _object; }
void Attach(HKEY key) { _object = key; }
HKEY Detach()
{
2024-11-29 01:00:00 +01:00
const HKEY key = _object;
2021-12-27 01:00:00 +01:00
_object = NULL;
return key;
}
LONG Create(HKEY parentKey, LPCTSTR keyName,
2024-11-29 01:00:00 +01:00
LPTSTR keyClass = REG_NONE,
DWORD options = REG_OPTION_NON_VOLATILE,
2021-12-27 01:00:00 +01:00
REGSAM accessMask = KEY_ALL_ACCESS,
LPSECURITY_ATTRIBUTES securityAttributes = NULL,
LPDWORD disposition = NULL) throw();
LONG Open(HKEY parentKey, LPCTSTR keyName, REGSAM accessMask = KEY_ALL_ACCESS) throw();
LONG Close() throw();
LONG DeleteSubKey(LPCTSTR subKeyName) throw();
LONG RecurseDeleteKey(LPCTSTR subKeyName) throw();
LONG DeleteValue(LPCTSTR name) throw();
2024-11-29 01:00:00 +01:00
#ifndef _UNICODE
2021-12-27 01:00:00 +01:00
LONG DeleteValue(LPCWSTR name);
2024-11-29 01:00:00 +01:00
#endif
2021-12-27 01:00:00 +01:00
LONG SetValue(LPCTSTR valueName, UInt32 value) throw();
LONG SetValue(LPCTSTR valueName, bool value) throw();
LONG SetValue(LPCTSTR valueName, LPCTSTR value) throw();
// LONG SetValue(LPCTSTR valueName, const CSysString &value);
2024-11-29 01:00:00 +01:00
#ifndef _UNICODE
2021-12-27 01:00:00 +01:00
LONG SetValue(LPCWSTR name, LPCWSTR value);
// LONG SetValue(LPCWSTR name, const UString &value);
2024-11-29 01:00:00 +01:00
#endif
2021-12-27 01:00:00 +01:00
LONG SetValue(LPCTSTR name, const void *value, UInt32 size) throw();
LONG SetValue_Strings(LPCTSTR valueName, const UStringVector &strings);
LONG GetValue_Strings(LPCTSTR valueName, UStringVector &strings);
LONG SetKeyValue(LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value) throw();
2024-11-29 01:00:00 +01:00
// GetValue_[type]_IfOk():
// if (return_result == ERROR_SUCCESS), (value) variable was read from registry
// if (return_result != ERROR_SUCCESS), (value) variable was not changed
LONG GetValue_UInt32_IfOk(LPCTSTR name, UInt32 &value) throw();
LONG GetValue_UInt64_IfOk(LPCTSTR name, UInt64 &value) throw();
LONG GetValue_bool_IfOk(LPCTSTR name, bool &value) throw();
2021-12-27 01:00:00 +01:00
2024-11-29 01:00:00 +01:00
// QueryValue():
// if (return_result == ERROR_SUCCESS), (value) string was read from registry
// if (return_result != ERROR_SUCCESS), (value) string was cleared
LONG QueryValue(LPCTSTR name, CSysString &value);
#ifndef _UNICODE
2021-12-27 01:00:00 +01:00
LONG QueryValue(LPCWSTR name, UString &value);
2024-11-29 01:00:00 +01:00
#endif
2021-12-27 01:00:00 +01:00
2024-11-29 01:00:00 +01:00
// QueryValue_Binary():
// if (return_result == ERROR_SUCCESS), (value) buffer was read from registry (BINARY data)
// if (return_result != ERROR_SUCCESS), (value) buffer was cleared
LONG QueryValue_Binary(LPCTSTR name, CByteBuffer &value);
2021-12-27 01:00:00 +01:00
LONG EnumKeys(CSysStringVector &keyNames);
};
}}
#endif