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
1 changed files with 22 additions and 21 deletions

View File

@ -274,22 +274,22 @@ 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]; WCHAR iid[50];
int i=0; int i=0;
BOOL moreKeys = TRUE;
while (ret && moreKeys) while (ret)
{ {
DWORD size; DWORD size;
LONG r;
size = sizeof (iid); size = sizeof (iid);
r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL); r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
@ -299,13 +299,14 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
i++; i++;
} }
else if (ERROR_NO_MORE_ITEMS == r) else if (ERROR_NO_MORE_ITEMS == r)
moreKeys = FALSE; break;
else else
ret = FALSE; ret = FALSE;
} }
RegCloseKey(hkey); RegCloseKey(hkey);
} }
} }
}
/* enumerate the elements in %windir%\desktop */ /* enumerate the elements in %windir%\desktop */
SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE); SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);