mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 10:11:22 +00:00
[CONCFG] Rewrite the InitTTFontCache() registry enumeration loop.
This commit is contained in:
parent
2a5536c540
commit
3b76aa5d19
1 changed files with 34 additions and 31 deletions
|
@ -399,51 +399,54 @@ IsValidConsoleFont(
|
||||||
VOID
|
VOID
|
||||||
InitTTFontCache(VOID)
|
InitTTFontCache(VOID)
|
||||||
{
|
{
|
||||||
BOOLEAN Success;
|
LRESULT lResult;
|
||||||
HKEY hKeyTTFonts; // hKey;
|
HKEY hKey;
|
||||||
DWORD dwNumValues = 0;
|
DWORD dwIndex, dwType;
|
||||||
DWORD dwIndex;
|
|
||||||
DWORD dwType;
|
|
||||||
WCHAR szValueName[MAX_PATH];
|
WCHAR szValueName[MAX_PATH];
|
||||||
DWORD dwValueName;
|
DWORD cchValueName;
|
||||||
WCHAR szValue[LF_FACESIZE] = L"";
|
WCHAR szValue[LF_FACESIZE] = L"";
|
||||||
DWORD dwValue;
|
DWORD cbValue;
|
||||||
PTT_FONT_ENTRY FontEntry;
|
|
||||||
PWCHAR pszNext = NULL;
|
|
||||||
UINT CodePage;
|
UINT CodePage;
|
||||||
|
PTT_FONT_ENTRY FontEntry;
|
||||||
|
PWCHAR pszNext;
|
||||||
|
|
||||||
if (!IsListEmpty(&TTFontCache))
|
if (!IsListEmpty(&TTFontCache))
|
||||||
return;
|
return;
|
||||||
// InitializeListHead(&TTFontCache);
|
// InitializeListHead(&TTFontCache);
|
||||||
|
|
||||||
/* Open the key */
|
/* Open the Console\TrueTypeFont key */
|
||||||
// "\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont"
|
// "\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont"
|
||||||
Success = (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont",
|
L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont",
|
||||||
0,
|
0,
|
||||||
KEY_READ,
|
KEY_QUERY_VALUE,
|
||||||
&hKeyTTFonts) == ERROR_SUCCESS);
|
&hKey) != ERROR_SUCCESS)
|
||||||
if (!Success)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Enumerate each value */
|
|
||||||
if (RegQueryInfoKeyW(hKeyTTFonts, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
&dwNumValues, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
DPRINT("ConCfgReadUserSettings: RegQueryInfoKeyW failed\n");
|
|
||||||
RegCloseKey(hKeyTTFonts);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dwIndex = 0; dwIndex < dwNumValues; dwIndex++)
|
/* Enumerate all the available TrueType console fonts */
|
||||||
|
for (dwIndex = 0, cchValueName = ARRAYSIZE(szValueName),
|
||||||
|
cbValue = sizeof(szValue);
|
||||||
|
(lResult = RegEnumValueW(hKey, dwIndex,
|
||||||
|
szValueName, &cchValueName,
|
||||||
|
NULL, &dwType,
|
||||||
|
(PBYTE)szValue, &cbValue)) != ERROR_NO_MORE_ITEMS;
|
||||||
|
++dwIndex, cchValueName = ARRAYSIZE(szValueName),
|
||||||
|
cbValue = sizeof(szValue))
|
||||||
{
|
{
|
||||||
dwValue = sizeof(szValue);
|
/* Ignore if we failed for another reason, e.g. because
|
||||||
dwValueName = ARRAYSIZE(szValueName);
|
* the value name is too long (and thus, invalid). */
|
||||||
if (RegEnumValueW(hKeyTTFonts, dwIndex, szValueName, &dwValueName, NULL, &dwType, (BYTE*)szValue, &dwValue) != ERROR_SUCCESS)
|
if (lResult != ERROR_SUCCESS)
|
||||||
{
|
|
||||||
DPRINT1("InitTTFontCache: RegEnumValueW failed, continuing...\n");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
/* Validate the value name (exclude the unnamed value) */
|
||||||
|
if (!cchValueName || (*szValueName == UNICODE_NULL))
|
||||||
|
continue;
|
||||||
|
/* Too large value names have already been handled with ERROR_MORE_DATA */
|
||||||
|
ASSERT((cchValueName < ARRAYSIZE(szValueName)) &&
|
||||||
|
(szValueName[cchValueName] == UNICODE_NULL));
|
||||||
|
|
||||||
/* Only (multi-)string values are supported */
|
/* Only (multi-)string values are supported */
|
||||||
if ((dwType != REG_SZ) && (dwType != REG_MULTI_SZ))
|
if ((dwType != REG_SZ) && (dwType != REG_MULTI_SZ))
|
||||||
continue;
|
continue;
|
||||||
|
@ -502,7 +505,7 @@ InitTTFontCache(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the key and quit */
|
/* Close the key and quit */
|
||||||
RegCloseKey(hKeyTTFonts);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue