LONG DeleteShellExtensionInfo(HKEY hkey, const CSysString &ext) { // NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey rootKey; rootKey.Attach(hkey); LONG res = rootKey.RecurseDeleteKey(GetExtKeyPath(hkey, ext)); // then we delete only 7-Zip.* key. rootKey.RecurseDeleteKey(GetFullKeyPath(hkey, GetExtProgramKeyName(ext))); rootKey.Detach(); return res; }
void SaveCompressionInfo(const NCompression::CInfo &info) { NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey compressionKey; compressionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kCompressionKeyName)); compressionKey.RecurseDeleteKey(kCompressionHistoryArchivesKeyName); { CKey historyArchivesKey; historyArchivesKey.Create(compressionKey, kCompressionHistoryArchivesKeyName); for(int i = 0; i < info.HistoryArchives.Size(); i++) { wchar_t numberString[16]; ConvertUInt64ToString(i, numberString); historyArchivesKey.SetValue(numberString, info.HistoryArchives[i]); } } // compressionKey.SetValue(kSolid, info.Solid); // compressionKey.SetValue(kMultiThread, info.MultiThread); compressionKey.RecurseDeleteKey(kCompressionOptionsKeyName); { CKey optionsKey; optionsKey.Create(compressionKey, kCompressionOptionsKeyName); for(int i = 0; i < info.FormatOptionsVector.Size(); i++) { const NCompression::CFormatOptions &fo = info.FormatOptionsVector[i]; CKey formatKey; formatKey.Create(optionsKey, fo.FormatID); SetRegString(formatKey, kCompressionOptions, fo.Options); SetRegString(formatKey, kCompressionMethod, fo.Method); SetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod); SetRegUInt32(formatKey, kCompressionLevel, fo.Level); SetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary); SetRegUInt32(formatKey, kCompressionOrder, fo.Order); SetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize); SetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads); } } compressionKey.SetValue(kCompressionLevelValueName, UInt32(info.Level)); compressionKey.SetValue(kCompressionLastFormatValueName, GetSystemString(info.ArchiveType)); compressionKey.SetValue(kCompressionShowPasswordValueName, info.ShowPassword); compressionKey.SetValue(kCompressionEncryptHeadersValueName, info.EncryptHeaders); // compressionKey.SetValue(kCompressionMaximizeValueName, info.Maximize); }
static void DeleteDragDropMenuHandlerCommon(const CSysString &keyName) { CKey rootKey; rootKey.Attach(HKEY_CLASSES_ROOT); rootKey.RecurseDeleteKey(GetFullDragDropMenuKeyName(keyName)); rootKey.Detach(); }
static void DeleteShellExtensionProgramKey(const CSysString &extension) { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey rootKey; rootKey.Attach(HKEY_CLASSES_ROOT); rootKey.RecurseDeleteKey(GetExtProgramKeyName(extension)); rootKey.Detach(); }
void WriteInternalAssociations(const CObjectVector<CExtInfo> &items) { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey mainKey; mainKey.Create(HKEY_CURRENT_USER, kCUKeyPath); mainKey.RecurseDeleteKey(kAssociations); CKey associationsKey; associationsKey.Create(mainKey, kAssociations); for(int i = 0; i < items.Size(); i++) { const CExtInfo &extInfo = items[i]; CKey key; key.Create(associationsKey, GetSystemString(extInfo.Ext)); key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins)); // key.SetValue(kExtEnabled, extInfo.Enabled); } }
void SaveExtractionInfo(const NExtract::CInfo &info) { NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey extractionKey; extractionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName)); extractionKey.RecurseDeleteKey(kExtractionPathHistoryKeyName); { CKey pathHistoryKey; pathHistoryKey.Create(extractionKey, kExtractionPathHistoryKeyName); for(int i = 0; i < info.Paths.Size(); i++) { wchar_t numberString[16]; ConvertUInt64ToString(i, numberString); pathHistoryKey.SetValue(numberString, info.Paths[i]); } } extractionKey.SetValue(kExtractionExtractModeValueName, UInt32(info.PathMode)); extractionKey.SetValue(kExtractionOverwriteModeValueName, UInt32(info.OverwriteMode)); extractionKey.SetValue(kExtractionShowPasswordValueName, info.ShowPassword); }
LONG CKey::RecurseDeleteKey(LPCTSTR subKeyName) throw() { CKey key; LONG res = key.Open(_object, subKeyName, KEY_READ | KEY_WRITE); if (res != ERROR_SUCCESS) return res; FILETIME fileTime; const UInt32 kBufferSize = MAX_PATH + 1; // 256 in ATL DWORD size = kBufferSize; TCHAR buffer[kBufferSize]; while (RegEnumKeyEx(key._object, 0, buffer, &size, NULL, NULL, NULL, &fileTime) == ERROR_SUCCESS) { res = key.RecurseDeleteKey(buffer); if (res != ERROR_SUCCESS) return res; size = kBufferSize; } key.Close(); return DeleteSubKey(subKeyName); }