bool _WriteValue(CTSTRING &tsValName, ValueType Type, const void *pVal, DWORD dwBytes) {

    bool r       = false;
    DWORD dwType = 0UL;

    switch (Type) {

      case VT_DWORD:  dwType = REG_DWORD; break;
      case VT_STRING: dwType = REG_SZ; break;
      case VT_BINARY: dwType = REG_BINARY; break;

    }

    if (ERROR_SUCCESS == RegSetValueEx(m_hKey, 
                                       (0 < tsValName.size()) ? tsValName.c_str() : NULL,
                                       0UL,
                                       dwType,
                                       static_cast<const BYTE *>(pVal),
                                       dwBytes))
    {

      r = true;

    }

    return r;
  }
  bool _ReadValue(CTSTRING &tsValName, ValueType Type, void *pVal, DWORD_PTR *pdwBytes) {

    bool r = false;

    if (ERROR_SUCCESS == RegQueryValueEx(m_hKey,
                                         (0 < tsValName.size()) ? tsValName.c_str() : NULL,
                                         0UL,
                                         NULL,
                                         static_cast<BYTE *>(pVal),
                                         pdwBytes))
    {

      r = true;

    }

    return r;
  }
  bool SetDefaultValue(CTSTRING &tsVal) {

    return _WriteValue(_T(""), VT_STRING, tsVal.c_str(), 
                       static_cast<DWORD>(tsVal.size() * sizeof (TCHAR)));
  }
  bool WriteString(CTSTRING &tsValName, CTSTRING &tsVal) {

    return _WriteValue(tsValName, VT_STRING, tsVal.c_str(),
                       static_cast<DWORD>(tsVal.size() * sizeof(TCHAR)));
  }