Author: gadamopoulos
Date: Sun Apr 21 12:21:21 2013
New Revision: 58798
URL:
http://svn.reactos.org/svn/reactos?rev=58798&view=rev
Log:
[desk.cpl]
- Add a missing error check
Modified:
trunk/reactos/dll/cpl/desk/background.c
Modified: trunk/reactos/dll/cpl/desk/background.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/background.c?…
==============================================================================
--- trunk/reactos/dll/cpl/desk/background.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/background.c [iso-8859-1] Sun Apr 21 12:21:21 2013
@@ -123,60 +123,62 @@
pData->listViewItemCount++;
/* Add current wallpaper if any */
- RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0,
KEY_ALL_ACCESS, ®Key);
-
- result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType,
(LPBYTE)wallpaperFilename, &bufferSize);
- if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
- {
- /* Allow environment variables in file name */
- if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
+ result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0,
KEY_ALL_ACCESS, ®Key);
+ if (result == ERROR_SUCCESS)
+ {
+ result = RegQueryValueEx(regKey, TEXT("Wallpaper"), 0, &varType,
(LPBYTE)wallpaperFilename, &bufferSize);
+ if ((result == ERROR_SUCCESS) && (_tcslen(wallpaperFilename) > 0))
{
- _tcscpy(wallpaperFilename, buffer);
+ /* Allow environment variables in file name */
+ if (ExpandEnvironmentStrings(wallpaperFilename, buffer, MAX_PATH))
+ {
+ _tcscpy(wallpaperFilename, buffer);
+ }
+
+ 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);
+ }
+
+ backgroundItem =
&pData->backgroundItems[pData->listViewItemCount];
+
+ backgroundItem->bWallpaper = TRUE;
+
+ _tcscpy(backgroundItem->szDisplayName, sfi.szDisplayName);
+ p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
+ if (p)
+ *p = (TCHAR)0;
+ _tcscpy(backgroundItem->szFilename, wallpaperFilename);
+
+ 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++;
+ }
}
- 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);
- }
-
- backgroundItem =
&pData->backgroundItems[pData->listViewItemCount];
-
- backgroundItem->bWallpaper = TRUE;
-
- _tcscpy(backgroundItem->szDisplayName, sfi.szDisplayName);
- p = _tcsrchr(backgroundItem->szDisplayName, _T('.'));
- if (p)
- *p = (TCHAR)0;
- _tcscpy(backgroundItem->szFilename, wallpaperFilename);
-
- 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. */