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; }
static void Load(const CSysString &folderPrefix) { NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*"))); NFile::NFind::CFileInfo fileInfo; while (enumerator.Next(fileInfo)) { if (fileInfo.IsDirectory()) continue; CSysString filePath = folderPrefix + fileInfo.Name; { NDLL::CLibrary library; if (!library.LoadEx(filePath, LOAD_LIBRARY_AS_DATAFILE)) continue; } NDLL::CLibrary library; if (!library.Load(filePath)) continue; GetMethodPropertyFunc getMethodProperty = (GetMethodPropertyFunc) library.GetProcAddress("GetMethodProperty"); if (getMethodProperty == NULL) continue; UInt32 numMethods = 1; GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc) library.GetProcAddress("GetNumberOfMethods"); if (getNumberOfMethodsFunc != NULL) if (getNumberOfMethodsFunc(&numMethods) != S_OK) continue; for(UInt32 i = 0; i < numMethods; i++) { CMethodInfo2 info; info.FilePath = filePath; NWindows::NCOM::CPropVariant propVariant; if (getMethodProperty(i, NMethodPropID::kID, &propVariant) != S_OK) continue; if (propVariant.vt != VT_BSTR) continue; info.MethodID.IDSize = SysStringByteLen(propVariant.bstrVal); memmove(info.MethodID.ID, propVariant.bstrVal, info.MethodID.IDSize); propVariant.Clear(); if (getMethodProperty(i, NMethodPropID::kName, &propVariant) != S_OK) continue; if (propVariant.vt == VT_EMPTY) { } else if (propVariant.vt == VT_BSTR) info.Name = propVariant.bstrVal; else continue; propVariant.Clear(); if (getMethodProperty (i, NMethodPropID::kEncoder, &propVariant) != S_OK) continue; if (propVariant.vt == VT_EMPTY) info.EncoderIsAssigned = false; else if (propVariant.vt == VT_BSTR) { info.EncoderIsAssigned = true; info.Encoder = *(const GUID *)propVariant.bstrVal; } else continue; propVariant.Clear(); if (getMethodProperty (i, NMethodPropID::kDecoder, &propVariant) != S_OK) continue; if (propVariant.vt == VT_EMPTY) info.DecoderIsAssigned = false; else if (propVariant.vt == VT_BSTR) { info.DecoderIsAssigned = true; info.Decoder = *(const GUID *)propVariant.bstrVal; } else continue; propVariant.Clear(); if (getMethodProperty (i, NMethodPropID::kInStreams, &propVariant) != S_OK) continue; if (propVariant.vt == VT_EMPTY) info.NumInStreams = 1; else if (propVariant.vt == VT_UI4) info.NumInStreams = propVariant.ulVal; else continue; propVariant.Clear(); if (getMethodProperty (i, NMethodPropID::kOutStreams, &propVariant) != S_OK) continue; if (propVariant.vt == VT_EMPTY) info.NumOutStreams = 1; else if (propVariant.vt == VT_UI4) info.NumOutStreams = propVariant.ulVal; else continue; propVariant.Clear(); g_Methods.Add(info); } } }
void AddVolumeItems(NWindows::NControl::CComboBox &combo) { for (unsigned i = 0; i < ARRAY_SIZE(k_Sizes); i++) combo.AddString(CSysString(k_Sizes[i])); }
static CSysString GetExtProgramKeyName(const CSysString &extension) { return CSysString(TEXT("7-Zip.")) + extension; }
static CSysString GetExtensionKeyName(const CSysString &extension) { return CSysString(TEXT(".")) + extension; }
static CSysString GetExtProgramKeyName(const CSysString &ext) { return CSysString(k7zipPrefix) + ext; }