[desk.cpl]

- Add a missing error check

svn path=/trunk/; revision=58798
This commit is contained in:
Giannis Adamopoulos 2013-04-21 12:21:21 +00:00
parent 78cb9a84f2
commit ade6d5011a

View file

@ -123,60 +123,62 @@ AddListViewItems(HWND hwndDlg, PDATA pData)
pData->listViewItemCount++; pData->listViewItemCount++;
/* Add current wallpaper if any */ /* Add current wallpaper if any */
RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_ALL_ACCESS, &regKey); result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_ALL_ACCESS, &regKey);
if (result == ERROR_SUCCESS)
result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
{ {
/* Allow environment variables in file name */ result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType, (LPBYTE)wallpaperFilename, &bufferSize);
if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH)) if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
{ {
_tcscpy(wallpaperFilename, buffer); /* Allow environment variables in file name */
} if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
himl = (HIMAGELIST)SHGetFileInfo(wallpaperFilename,
0,
&sfi,
sizeof(sfi),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON |
SHGFI_DISPLAYNAME);
if (himl != NULL)
{
if (i++ == 0)
{ {
(void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL); _tcscpy(wallpaperFilename, buffer);
} }
backgroundItem = &pData->backgroundItems[pData->listViewItemCount]; himl = (HIMAGELIST)SHGetFileInfo(wallpaperFilename,
0,
&sfi,
sizeof(sfi),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON |
SHGFI_DISPLAYNAME);
backgroundItem->bWallpaper = TRUE; if (himl != NULL)
{
if (i++ == 0)
{
(void)ListView_SetImageList(hwndBackgroundList, himl, LVSIL_SMALL);
}
_tcscpy(backgroundItem->szDisplayName, sfi.szDisplayName); backgroundItem = &pData->backgroundItems[pData->listViewItemCount];
p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
if (p)
*p = (TCHAR)0;
_tcscpy(backgroundItem->szFilename, wallpaperFilename);
ZeroMemory(&listItem, sizeof(LV_ITEM)); backgroundItem->bWallpaper = TRUE;
listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
listItem.state = 0;
listItem.pszText = backgroundItem->szDisplayName;
listItem.iImage = sfi.iIcon;
listItem.iItem = pData->listViewItemCount;
listItem.lParam = pData->listViewItemCount;
(void)ListView_InsertItem(hwndBackgroundList, &listItem); _tcscpy(backgroundItem->szDisplayName, sfi.szDisplayName);
ListView_SetItemState(hwndBackgroundList, p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
pData->listViewItemCount, if (p)
LVIS_SELECTED, *p = (TCHAR)0;
LVIS_SELECTED); _tcscpy(backgroundItem->szFilename, wallpaperFilename);
pData->listViewItemCount++; ZeroMemory(&listItem, sizeof(LV_ITEM));
listItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
listItem.state = 0;
listItem.pszText = backgroundItem->szDisplayName;
listItem.iImage = sfi.iIcon;
listItem.iItem = pData->listViewItemCount;
listItem.lParam = pData->listViewItemCount;
(void)ListView_InsertItem(hwndBackgroundList, &listItem);
ListView_SetItemState(hwndBackgroundList,
pData->listViewItemCount,
LVIS_SELECTED,
LVIS_SELECTED);
pData->listViewItemCount++;
}
} }
}
RegCloseKey(regKey); RegCloseKey(regKey);
}
/* Add all the images in the C:\ReactOS directory. */ /* Add all the images in the C:\ReactOS directory. */