void InitializeParameters::save() { RegistryKey key = getKey(); key.setValue(_T("elementcount") ,(UINT)m_elementCount ); key.setValue(_T("elementsize") ,m_elementSize ); key.setValue(_T("initmethod") ,initMethodToName(m_initMethod)); key.setValue(_T("randomize") ,m_randomizationMethod ); key.setValue(_T("seed") ,m_seed ); key.setValue(_T("periodcount") ,m_periodCount ); key.setValue(_T("filename") ,m_fileName ); }
History::~History () { char subKey[256]; strcpy (subKey, HKCU_SUBKEY_HERMIT "\\"); strcat (subKey, mName); try { RegistryKey k (HKEY_CURRENT_USER, subKey, KEY_READ | KEY_WRITE); char str[3]; for (int j = 0; j < HIST_SIZE; j++) { wsprintf (str, "%d", j); const char *value = mpText[j]; if (value == 0) value = ""; k.setValue (str, value); } } catch (const std::exception&) { // oh well, it's only the history } for (int i = 0; i < HIST_SIZE; i++) if (mpText[i] != 0) free (mpText[i]); }
void Options::save() { try { RegistryKey settings = getKey(); settings.setValue(_T("dirlist") ,m_dirList ); settings.setValue(_T("startselectdir") ,m_startSelectDir ); settings.setValue(_T("confirmchoise") ,m_confirmChoise ); settings.setValue(_T("autoselect") ,m_autoSelect ); settings.setValue(_T("allowduplicates") ,m_allowDuplicates ); // settings.setValue(_T("password") ,m_md5password ); // NB settings.setValue(_T("maxchoise") ,m_maxChoise ); settings.setValue(_T("volume") ,m_volume ); settings.setValue(_T("backgroundcolor") ,m_backgroundColor ); settings.setValue(_T("currentcolor") ,m_currentTrackColor ); settings.setValue(_T("playqueuecolor") ,m_mediaQueueColor ); } catch(Exception e) { showException(e); } }
const char *ConfigScroller::importCommands (const char *path) { FILE *file = fopen (path, "r"); if (file == NULL) return "Could not open file"; ArrayPtr<char> str = new char [COMMAND_SIZE + 3]; if (str == 0) throw AppException (WHERE, ERR_OUT_OF_MEMORY); char *status = 0; while (fgets (str, COMMAND_SIZE + 3, file) != NULL) { // Remove trailing whitespace int n = (int) strlen (str); while (n > 0 && (str[n - 1] == '\n' || str[n - 1] == '\t' || str[n - 1] == ' ')) { str[n - 1] = '\0'; n--; } // If string is empty, just ignore it if (str[0] == '\0') continue; // Uppercase the first letter str[0] = toupper (str[0]); // Make sure the command format is [A-Z,0-9], if ((!(str[0] >= 'A' && str[0] <= 'Z') && !(str[0] >= '0' && str[0] <= '9')) || str[1] != ',') { status = "A read error occurred."; break; } // Create the value name string char valname[2]; valname[0] = str[0]; valname[1] = '\0'; // Save to registry try { // Open registry key RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Commands", KEY_READ | KEY_WRITE); k.setValue (valname, &str[2]); } catch (const std::exception&) { status = "Error saving key to registry"; break; } } if (ferror (file) != 0) status = "A read error occurred."; if (status == 0) { // Set initialized state (actually no reason...we use Commands key) #if 0 try { RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Initialized", KEY_READ | KEY_WRITE); } catch (const std::exception&) { } #endif // Set message status = "Commands imported."; } fclose (file); return status; }