void GetCurrentParamsPath(TSTRING &tsPath) { RegistryKey Key; if (!Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) { MessageBox(GetForegroundWindow(), _T("Failed to open registry key that contains current image parameters file path;") _T(" reverting to defaults."), _T("FURR - Error"), MB_OK | MB_ICONSTOP); GetAppPath(tsPath); tsPath += FURR_DEFIMAGEPARAMSFILE; } if (!Key.ReadString(FURR_CURIMAGEPARAMSVALUE, tsPath)) { MessageBox(GetForegroundWindow(), _T("Failed to read registry key that contains current image parameters file path;") _T(" reverting to defaults."), _T("FURR - Error"), MB_OK | MB_ICONSTOP); GetAppPath(tsPath); tsPath += FURR_DEFIMAGEPARAMSFILE; } if (_T("") == tsPath) { MessageBox(GetForegroundWindow(), _T("No current image parameters file is saved in the registry; reverting to defaults."), _T("FURR - Information"), MB_OK | MB_ICONINFORMATION); GetAppPath(tsPath); tsPath += FURR_DEFIMAGEPARAMSFILE; } }
DWORD ServiceParametersBase::ServiceParamInstall(void) { RegistryKey regKey; // Registry key wrapper object PSERVICE_PARAMETER_MAP pParamMap; // Pointer to a SERVICE_PARAMETER_ENTRY DWORD dwResult; // Result from function call // Attempt to create the service parameters registry key object, and // open it with both KEY_READ and KEY_WRITE access dwResult = regKey.Create(HKEY_LOCAL_MACHINE, GetParametersKeyName(), KEY_READ | KEY_WRITE); if(dwResult != ERROR_SUCCESS) return dwResult; pParamMap = GetParameterMap(); // Retrieve the PARAMETER_MAP _ASSERTE(pParamMap != NULL); // Should never be NULL // Loop through the PARAMETER_MAP and add any parameters that are not already // set up in the registry key. We don't worry about failure too much in here, // since the Parameter class will always provide a default value if need be while(pParamMap->pEntry) { if(pParamMap->pEntry->Load(regKey) != ERROR_SUCCESS) pParamMap->pEntry->Save(regKey); pParamMap++; // Move to the next parameter } return ERROR_SUCCESS; }
void GetCurrentPreviewImage(TSTRING &tsImgPath) { RegistryKey Key; if (!Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) { MessageBox(GetForegroundWindow(), _T("Failed to open registry key that contains current preview image path!"), _T("FURR - Error"), MB_OK | MB_ICONSTOP); } Key.ReadString(FURR_CURPREVIEWIMAGEVALUE, tsImgPath); }
bool SetCurrentParamsPath(CTSTRING &tsPath) { bool r = false; RegistryKey Key; if (Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) { if (Key.WriteString(FURR_CURIMAGEPARAMSVALUE, tsPath)) { r = true; } } return r; }