[REGEDIT] Fix issue at Find registry key (#4341)

- If we dont select a item as a starting point to search from, we need to set
  pszValueName to the first value name in current subkey.

- Check pszSubKey length before calling RegFindRecurse.

- Set focus to subkey when we search for it.
This commit is contained in:
Jose Carlos Jesus 2022-06-19 20:57:30 +01:00 committed by GitHub
parent 65d7fb1a82
commit 568383c9b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -160,9 +160,6 @@ BOOL RegFindRecurse(
if (lResult != ERROR_SUCCESS)
return FALSE;
if (pszValueName == NULL)
pszValueName = s_empty;
lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL,
&c, NULL, NULL, NULL, NULL);
if (lResult != ERROR_SUCCESS)
@ -195,6 +192,9 @@ BOOL RegFindRecurse(
qsort(ppszNames, c, sizeof(LPWSTR), compare);
if (pszValueName == NULL)
pszValueName = ppszNames[0];
for(i = 0; i < c; i++)
{
if (DoEvents())
@ -370,13 +370,14 @@ BOOL RegFindWalk(
LPWSTR *ppszNames = NULL;
hBaseKey = *phKey;
if (wcslen(pszSubKey) >= _countof(szSubKey))
return FALSE;
if (RegFindRecurse(hBaseKey, pszSubKey, pszValueName, ppszFoundSubKey,
ppszFoundValueName))
return TRUE;
if (wcslen(pszSubKey) >= MAX_PATH)
return FALSE;
wcscpy(szSubKey, pszSubKey);
while(szSubKey[0] != 0)
{
@ -687,10 +688,18 @@ BOOL FindNext(HWND hWnd)
{
GetKeyName(szFullKey, COUNT_OF(szFullKey), hKeyRoot, pszFoundSubKey);
SelectNode(g_pChildWnd->hTreeWnd, szFullKey);
SetValueName(g_pChildWnd->hListWnd, pszFoundValueName);
free(pszFoundSubKey);
free(pszFoundValueName);
SetFocus(g_pChildWnd->hListWnd);
if (pszFoundValueName != NULL)
{
SetValueName(g_pChildWnd->hListWnd, pszFoundValueName);
free(pszFoundValueName);
SetFocus(g_pChildWnd->hListWnd);
}
else
{
SetFocus(g_pChildWnd->hTreeWnd);
}
}
return fSuccess || s_bAbort;
}