Also scan HKEY_CURRENT_USER for shell namespace extensions in Desktop

folder.
Fixed a handle leak in case of failing AddToEnumList call.
This commit is contained in:
Michael Jung 2005-11-23 15:17:54 +01:00 committed by Alexandre Julliard
parent b2647030c4
commit 46018bbc59

View File

@ -274,36 +274,37 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
if (dwFlags & SHCONTF_FOLDERS) if (dwFlags & SHCONTF_FOLDERS)
{ {
HKEY hkey; HKEY hkey;
LONG r; UINT i;
/* create the pidl for This item */ /* create the pidl for This item */
ret = AddToEnumList(list, _ILCreateMyComputer()); ret = AddToEnumList(list, _ILCreateMyComputer());
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, Desktop_NameSpaceW, for (i=0; i<2; i++) {
0, KEY_READ, &hkey); if (ret && !RegOpenKeyExW(i == 0 ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
if (ret && ERROR_SUCCESS == r) Desktop_NameSpaceW, 0, KEY_READ, &hkey))
{
WCHAR iid[50];
int i=0;
BOOL moreKeys = TRUE;
while (ret && moreKeys)
{ {
DWORD size; WCHAR iid[50];
int i=0;
size = sizeof (iid); while (ret)
r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
if (ERROR_SUCCESS == r)
{ {
ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid)); DWORD size;
i++; LONG r;
size = sizeof (iid);
r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
if (ERROR_SUCCESS == r)
{
ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid));
i++;
}
else if (ERROR_NO_MORE_ITEMS == r)
break;
else
ret = FALSE;
} }
else if (ERROR_NO_MORE_ITEMS == r) RegCloseKey(hkey);
moreKeys = FALSE;
else
ret = FALSE;
} }
RegCloseKey(hkey);
} }
} }