📄 reg_key.hpp
字号:
* will be thrown if the value cannot be set.
*/
bool_type set_value(char_type const* valueName, char_type const* value, ws_uint_t type = REG_SZ);
/** \brief Sets the named value to the values of the given string array.
///
/// \param valueName The name of the value.
/// \param values The string array.
/// \param numValues Number of elements in the string array.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
bool_type set_value(char_type const* valueName, char_type const** values, size_type numValues);
/** \brief Sets the named value to the given binary value.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
bool_type set_value(char_type const* valueName, void const* value, size_type cbValue);
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Sets the named value to the value of the given 32-bit integer.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
template <ss_typename_param_k S>
bool_type set_value(S const& valueName, DWORD value)
{
return set_value_(stlsoft_ns_qual(c_str_ptr)(valueName), value);
}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
#ifdef STLSOFT_CF_64BIT_INT_SUPPORT
# ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Sets the named value to the value of the given 64-bit integer.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
template <ss_typename_param_k S>
bool_type set_value(S const& valueName, ws_uint64_t value)
{
return set_value_(stlsoft_ns_qual(c_str_ptr)(valueName), value);
}
# endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
#endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Sets the named value to the value of the given string.
///
/// \param valueName The name of the value.
/// \param value The value of the value
/// \param type The type of the value. Must be one of REG_SZ, REG_EXPAND_SZ or REG_MULTI_SZ.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
template <ss_typename_param_k S>
bool_type set_value(S const& valueName, char_type const* value, ws_uint_t type = REG_SZ)
{
return set_value_(stlsoft_ns_qual(c_str_ptr)(valueName), value, type);
}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Sets the named value to the values of the given string array.
///
/// \param valueName The name of the value.
/// \param values The string array.
/// \param numValues Number of elements in the string array.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
template <ss_typename_param_k S>
bool_type set_value(S const& valueName, char_type const** values, size_type numValues)
{
return set_value_(stlsoft_ns_qual(c_str_ptr)(valueName), values, numValues);
}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Sets the named value to the given binary value.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
template <ss_typename_param_k S>
bool_type set_value(S const& valueName, void const* value, size_type cbValue)
{
return set_value_(stlsoft_ns_qual(c_str_ptr)(valueName), value, cbValue);
}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
/** \brief Sets the named value to the given integer (stored as an unsigned value).
///
/// \note This method is provided solely to disambiguate between the DWORD and ws_uint64_t overloads
/// when using integer literals.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
bool_type set_value(char_type const* valueName, int value);
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Sets the named value to the given integer (stored as an unsigned value).
///
/// \note This method is provided solely to disambiguate between the DWORD and ws_uint64_t overloads
/// when using integer literals.
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value cannot be set.
*/
template <ss_typename_param_k S>
bool_type set_value(S const& valueName, int value)
{
return set_value_(stlsoft_ns_qual(c_str_ptr)(valueName), value);
}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
/** \brief Deletes the named value.
*
* \param valueName The name of the value to be deleted.
*
* \return Indicates whether the value was deleted.
* \retval true The value existed and was successfully deleted.
* \retval false The value does not exist. (<b>Note</b>:
* if \ref page__exception_agnostic "exception handling is not enabled",
* then false will also be returned for any other reason, and the
* reason will be available via <code>::GetLastError()</code>.)
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value exists but cannot be deleted.
*/
bool_type delete_value(char_type const* valueName);
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Deletes the named value.
*
* \param valueName The name of the value to be deleted.
*
* \return Indicates whether the value was deleted.
* \retval true The value existed and was successfully deleted.
* \retval false The value does not exist. (<b>Note</b>:
* if \ref page__exception_agnostic "exception handling is not enabled",
* then false will also be returned for any other reason, and the
* reason will be available via <code>::GetLastError()</code>.)
*
* \exception winstl::registry_exception If \ref page__exception_agnostic "exception handling is enabled",
* an instance of \link winstl::registry_exception registry_exception\endlink
* will be thrown if the value exists but cannot be deleted.
*/
template <ss_typename_param_k S>
bool_type delete_value(S const& valueName)
{
return this->delete_value_(stlsoft_ns_qual(c_str_ptr)(valueName));
}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
#if 0
ws_dword_t get_value_type(char_type const* valueName) const;
size_type get_value_data_size(char_type const* valueName) const;
#endif /* 0 */
/** \brief Returns the named value.
///
/// \return An instance of basic_reg_value.
*/
key_value_type get_value(char_type const* valueName) const;
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/** \brief Returns the named value.
///
/// \return An instance of basic_reg_value.
*/
template <ss_typename_param_k S>
key_value_type get_value(S const& valueName) const
{
return this->get_value(stlsoft_ns_qual(c_str_ptr)(stlsoft_ns_qual(c_str_ptr)(valueName)));
}
#endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */
// std::list<key_value_type> get_values(char_type const* valueNames) const;
/// @}
/// \name Implementation
/// @{
private:
static hkey_type open_key_( hkey_type hkeyParent
, char_type const* keyName
, REGSAM accessMask);
class_type open_sub_key_( char_type const* subKeyName
, REGSAM accessMask);
class_type create_sub_key_( char_type const* subKeyName
, REGSAM accessMask);
bool_type delete_sub_key_( char_type const* subKeyName);
static result_type set_value_( hkey_type hkey
, char_type const* valueName
, ws_uint_t type
, void const *value
, size_type cbValue);
bool_type set_value_int_(char_type const* valueName, int value, stlsoft_ns_qual(yes_type));
bool_type set_value_int_(char_type const* valueName, int value, stlsoft_ns_qual(no_type));
bool_type set_value_(char_type const* valueName, DWORD value);
# ifdef STLSOFT_CF_64BIT_INT_SUPPORT
bool_type set_value_(char_type const* valueName, ws_uint64_t value);
# endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
bool_type set_value_(char_type const* valueName, char_type const* value, ws_uint_t type);
bool_type set_value_(char_type const* valueName, char_type const** values, size_type numValues);
bool_type set_value_(char_type const* valueName, void const* value, size_type cbValue);
bool_type set_value_(char_type const* valueName, int value);
bool_type delete_value_(char_type const* valueName);
static result_type get_value_(hkey_type hkey, char_type const* valueName, ws_uint_t type, void *value, size_type *pcbValue);
static hkey_type dup_key_( hkey_type hkey
, REGSAM accessMask = KEY_ALL_ACCESS);
/// @}
/// \name Operations
/// @{
public:
/** \brief Efficiently swaps the contents between two instances
///
/// \param rhs The parameter whose contents will be swapped.
*/
void swap(class_type& rhs) stlsoft_throw_0();
/// @}
/// \name Members
/// @{
private:
hkey_type m_hkey; // The key handle
string_type m_name; // The key name
REGSAM m_accessMask; // The security access mask
/// @}
};
/* Typedefs to commonly encountered types. */
/** \brief Specialisation of the basic_reg_key template for the ANSI character type \c char
*
* \ingroup group__library__windows_registry
*/
typedef basic_reg_key<ws_char_a_t, reg_traits<ws_char_a_t>, processheap_allocator<ws_char_a_t> > reg_key_a;
/** \brief Specialisation of the basic_reg_key template for the Unicode character type \c wchar_t
*
* \ingroup group__library__windows_registry
*/
typedef basic_reg_key<ws_char_w_t, reg_traits<ws_char_w_t>, processheap_allocator<ws_char_w_t> > reg_key_w;
/** \brief Specialisation of the basic_reg_key template for the Win32 character type \c TCHAR
*
* \ingroup group__library__windows_registry
*/
typedef basic_reg_key<TCHAR, reg_traits<TCHAR>, processheap_allocator<TCHAR> > reg_key;
/* /////////////////////////////////////////////////////////////////////////
* Handle access shims
*/
/* get_handle */
/** \brief [\ref group__concept__shims "Shim" function] Returns the corresponding registry handle of an instance of winstl::basic_reg_key basic_reg_key.
*
* \ingroup group__library__windows_registry
*
* \param key The \link winstl::basic_reg_key basic_reg_key\endlink instance.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -