void ReadWorkDirInfo(NWorkDir::CInfo &info) { info.SetDefault(); NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey optionsKey; if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS) return; UInt32 dirType; if (optionsKey.QueryValue(kWorkDirTypeValueName, dirType) != ERROR_SUCCESS) return; switch (dirType) { case NWorkDir::NMode::kSystem: case NWorkDir::NMode::kCurrent: case NWorkDir::NMode::kSpecified: info.Mode = NWorkDir::NMode::EEnum(dirType); } UString sysWorkDir; if (optionsKey.QueryValue(kWorkDirPathValueName, sysWorkDir) != ERROR_SUCCESS) { info.Path.Empty(); if (info.Mode == NWorkDir::NMode::kSpecified) info.Mode = NWorkDir::NMode::kSystem; } info.Path = GetUnicodeString(sysWorkDir); if (optionsKey.QueryValue(kTempRemovableOnlyValueName, info.ForRemovableOnly) != ERROR_SUCCESS) info.SetForRemovableOnlyDefault(); }
void ReadExtractionInfo(NExtract::CInfo &info) { info.Paths.Clear(); info.PathMode = NExtract::NPathMode::kCurrentPathnames; info.OverwriteMode = NExtract::NOverwriteMode::kAskBefore; info.ShowPassword = false; NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey extractionKey; if(extractionKey.Open(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName), KEY_READ) != ERROR_SUCCESS) return; { CKey pathHistoryKey; if(pathHistoryKey.Open(extractionKey, kExtractionPathHistoryKeyName, KEY_READ) == ERROR_SUCCESS) { for (;;) { wchar_t numberString[16]; ConvertUInt64ToString(info.Paths.Size(), numberString); UString path; if (pathHistoryKey.QueryValue(numberString, path) != ERROR_SUCCESS) break; info.Paths.Add(path); } } } UInt32 extractModeIndex; if (extractionKey.QueryValue(kExtractionExtractModeValueName, extractModeIndex) == ERROR_SUCCESS) { switch (extractModeIndex) { case NExtract::NPathMode::kFullPathnames: case NExtract::NPathMode::kCurrentPathnames: case NExtract::NPathMode::kNoPathnames: info.PathMode = NExtract::NPathMode::EEnum(extractModeIndex); break; } } UInt32 overwriteModeIndex; if (extractionKey.QueryValue(kExtractionOverwriteModeValueName, overwriteModeIndex) == ERROR_SUCCESS) { switch (overwriteModeIndex) { case NExtract::NOverwriteMode::kAskBefore: case NExtract::NOverwriteMode::kWithoutPrompt: case NExtract::NOverwriteMode::kSkipExisting: case NExtract::NOverwriteMode::kAutoRename: case NExtract::NOverwriteMode::kAutoRenameExisting: info.OverwriteMode = NExtract::NOverwriteMode::EEnum(overwriteModeIndex); break; } } if (extractionKey.QueryValue(kExtractionShowPasswordValueName, info.ShowPassword) != ERROR_SUCCESS) info.ShowPassword = false; }
void ReadInternalAssociations(CObjectVector<CExtInfo> &items) { items.Clear(); NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey associationsKey; if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS) return; CSysStringVector extNames; associationsKey.EnumKeys(extNames); for(int i = 0; i < extNames.Size(); i++) { const CSysString extName = extNames[i]; CExtInfo extInfo; // extInfo.Enabled = false; extInfo.Ext = GetUnicodeString(extName); CKey key; if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS) return; UString pluginsString; key.QueryValue(kExtPlugins, pluginsString); SplitString(pluginsString, extInfo.Plugins); /* if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS) extInfo.Enabled = false; */ items.Add(extInfo); } }
bool ReadUi32Val(const TCHAR *name, UInt32 &value) { CKey key; if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return false; return key.QueryValue(name, value) == ERROR_SUCCESS; }
void ReadRegLang(UString &langFile) { langFile.Empty(); CKey key; if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS) key.QueryValue(kLangValueName, langFile); }
void ReadRegEditor(UString &editorPath) { editorPath.Empty(); CKey key; if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS) key.QueryValue(kEditor, editorPath); }
static bool ReadValue(const TCHAR *value, UInt32 &result) { NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey optionsKey; if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS) return false; return (optionsKey.QueryValue(value, result) == ERROR_SUCCESS); }
bool ReadPanelPath(UInt32 panel, UString &path) { NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return false; return (key.QueryValue(GetPanelPathName(panel), path) == ERROR_SUCCESS); }
static bool CheckHandlerCommon(const CSysString &keyName, UInt32 wow) { CKey key; if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ | wow) != ERROR_SUCCESS) return false; CSysString value; if (key.QueryValue(NULL, value) != ERROR_SUCCESS) return false; return StringsAreEqualNoCase_Ascii(value, k_Clsid); }
static bool ReadOption(const TCHAR *value, bool defaultValue) { NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey optionsKey; if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS) return defaultValue; bool enabled; if (optionsKey.QueryValue(value, enabled) != ERROR_SUCCESS) return defaultValue; return enabled; }
static bool ReadOption(const TCHAR *value, bool defaultValue) { CKey key; if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS) { bool enabled; if (key.QueryValue(value, enabled) == ERROR_SUCCESS) return enabled; } return defaultValue; }
static bool CheckHandlerCommon(const CSysString &keyName) { NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ) != ERROR_SUCCESS) return false; CSysString value; if (key.QueryValue(NULL, value) != ERROR_SUCCESS) return false; return StringsAreEqualNoCase_Ascii(value, kExtensionCLSID); }
static bool CheckDragDropMenuHandlerCommon(const CSysString &keyName) { NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey key; if (key.Open(HKEY_CLASSES_ROOT, GetFullDragDropMenuKeyName(keyName), KEY_READ) != ERROR_SUCCESS) return false; CSysString value; if (key.QueryValue(NULL, value) != ERROR_SUCCESS) return false; return (value.CompareNoCase(kExtensionCLSID) == 0); }
static bool CheckHandlerCommon(const CSysString &keyName) { NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ) != ERROR_SUCCESS) return false; CSysString value; if (key.QueryValue(NULL, value) != ERROR_SUCCESS) return false; value.MakeUpper(); return (value.Compare(kExtensionCLSID) == 0); }
bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo) { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey key; if (key.Open(HKEY_CURRENT_USER, CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) + GetSystemString(ext), KEY_READ) != ERROR_SUCCESS) return false; UString pluginsString; key.QueryValue(kExtPlugins, pluginsString); SplitString(pluginsString, extInfo.Plugins); return true; }
bool CShellExtInfo::ReadFromRegistry(HKEY hkey, const CSysString &ext) { ProgramKey.Empty(); IconPath.Empty(); IconIndex = -1; // NSynchronization::CCriticalSectionLock lock(g_CriticalSection); { CKey extKey; if (extKey.Open(hkey, GetExtKeyPath(hkey, ext), KEY_READ) != ERROR_SUCCESS) return false; if (extKey.QueryValue(NULL, ProgramKey) != ERROR_SUCCESS) return false; } { CKey iconKey; if (iconKey.Open(hkey, GetFullKeyPath(hkey, ProgramKey + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName), KEY_READ) == ERROR_SUCCESS) { UString value; if (iconKey.QueryValue(NULL, value) == ERROR_SUCCESS) { int pos = value.ReverseFind(L','); IconPath = value; if (pos >= 0) { const wchar_t *end; Int32 index = ConvertStringToInt32((const wchar_t *)value + pos + 1, &end); if (*end == 0) { // 9.31: if there is no icon index, we use -1. Is it OK? if (pos != (int)value.Len() - 1) IconIndex = (int)index; IconPath.SetFrom(value, pos); } } } } } return true; }
static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconPath, int &iconIndex) { iconIndex = -1; iconPath.Empty(); NSynchronization::CCriticalSectionLock lock(g_CriticalSection); CKey extKey; if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS) return false; CSysString programNameValue; if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS) return false; CSysString extProgramKeyName = GetExtProgramKeyName(extension); UString programNameValueU = GetUnicodeString(programNameValue); if (programNameValueU.CompareNoCase(GetUnicodeString(extProgramKeyName)) != 0) return false; CKey iconKey; if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS) return false; UString value; if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS) { int pos = value.ReverseFind(L','); iconPath = value; if (pos >= 0) { const wchar_t *end; UInt64 index = ConvertStringToUInt64((const wchar_t *)value + pos + 1, &end); if (*end == 0) { iconIndex = (int)index; iconPath = value.Left(pos); } } } return true; }
void CListViewInfo::Read(const UString &id) { Clear(); CByteBuffer buf; UInt32 size; { NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; if (key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS) return; if (key.QueryValue(GetSystemString(id), buf, size) != ERROR_SUCCESS) return; } if (size < kListViewHeaderSize) return; UInt32 version; Get32(buf, version); if (version != kListViewVersion) return; Get32(buf + 4, SortID); GetBool(buf + 8, Ascending); size -= kListViewHeaderSize; if (size % kColumnInfoSize != 0) return; unsigned numItems = size / kColumnInfoSize; Columns.ClearAndReserve(numItems); for (unsigned i = 0; i < numItems; i++) { CColumnInfo column; const Byte *p = buf + kListViewHeaderSize + i * kColumnInfoSize; Get32(p, column.PropID); GetBool(p + 4, column.IsVisible); Get32(p + 8, column.Width); Columns.AddInReserved(column); } }
static void GetRegUInt32(CKey &key, const TCHAR *name, UInt32 &value) { if (key.QueryValue(name, value) != ERROR_SUCCESS) value = (UInt32)-1; }
static void GetRegString(CKey &key, const WCHAR *name, UString &value) { if (key.QueryValue(name, value) != ERROR_SUCCESS) value.Empty(); }
static bool QueryBuf(CKey &key, LPCTSTR name, CByteBuffer &buf, UInt32 dataSize) { UInt32 size; return key.QueryValue(name, buf, size) == ERROR_SUCCESS && size == dataSize; }
void ReadCompressionInfo(NCompression::CInfo &info) { info.HistoryArchives.Clear(); // info.Solid = true; // info.MultiThread = IsMultiProcessor(); info.FormatOptionsVector.Clear(); info.Level = 5; info.ArchiveType = L"7z"; // definedStatus.Maximize = false; info.ShowPassword = false; info.EncryptHeaders = false; NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); CKey compressionKey; if(compressionKey.Open(HKEY_CURRENT_USER, GetKeyPath(kCompressionKeyName), KEY_READ) != ERROR_SUCCESS) return; { CKey historyArchivesKey; if(historyArchivesKey.Open(compressionKey, kCompressionHistoryArchivesKeyName, KEY_READ) == ERROR_SUCCESS) { for (;;) { wchar_t numberString[16]; ConvertUInt64ToString(info.HistoryArchives.Size(), numberString); UString path; if (historyArchivesKey.QueryValue(numberString, path) != ERROR_SUCCESS) break; info.HistoryArchives.Add(path); } } } /* bool solid = false; if (compressionKey.QueryValue(kSolid, solid) == ERROR_SUCCESS) info.Solid = solid; bool multiThread = false; if (compressionKey.QueryValue(kMultiThread, multiThread) == ERROR_SUCCESS) info.MultiThread = multiThread; */ { CKey optionsKey; if(optionsKey.Open(compressionKey, kCompressionOptionsKeyName, KEY_READ) == ERROR_SUCCESS) { CSysStringVector formatIDs; optionsKey.EnumKeys(formatIDs); for(int i = 0; i < formatIDs.Size(); i++) { CKey formatKey; NCompression::CFormatOptions fo; fo.FormatID = formatIDs[i]; if(formatKey.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS) { GetRegString(formatKey, kCompressionOptions, fo.Options); GetRegString(formatKey, kCompressionMethod, fo.Method); GetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod); GetRegUInt32(formatKey, kCompressionLevel, fo.Level); GetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary); GetRegUInt32(formatKey, kCompressionOrder, fo.Order); GetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize); GetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads); info.FormatOptionsVector.Add(fo); } } } } UInt32 level; if (compressionKey.QueryValue(kCompressionLevelValueName, level) == ERROR_SUCCESS) info.Level = level; CSysString archiveType; if (compressionKey.QueryValue(kCompressionLastFormatValueName, archiveType) == ERROR_SUCCESS) info.ArchiveType = GetUnicodeString(archiveType); if (compressionKey.QueryValue(kCompressionShowPasswordValueName, info.ShowPassword) != ERROR_SUCCESS) info.ShowPassword = false; if (compressionKey.QueryValue(kCompressionEncryptHeadersValueName, info.EncryptHeaders) != ERROR_SUCCESS) info.EncryptHeaders = false; /* if (compressionKey.QueryValue(kCompressionLevelValueName, info.Maximize) == ERROR_SUCCESS) definedStatus.Maximize = true; */ }