Skip to content

Commit fef579f

Browse files
authored
Update WindowsWallpaperService.cs
1 parent f006d34 commit fef579f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Files.App/Services/Windows/WindowsWallpaperService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths)
6363
(void**)pDesktopWallpaper.GetAddressOf())
6464
.ThrowOnFailure();
6565

66+
uint dwCount = (uint)aszPaths.Length;
6667
ITEMIDLIST** ppItemIdList = stackalloc ITEMIDLIST*[aszPaths.Length];
6768

6869
// Get array of PIDL from the selected image files
69-
for (uint dwIndex = 0u; dwIndex < (uint)aszPaths.Length; dwIndex++)
70+
for (uint dwIndex = 0u; dwIndex < dwCount; dwIndex++)
7071
ppItemIdList[dwIndex] = PInvoke.ILCreateFromPath(aszPaths[dwIndex]);
7172

7273
// Get a shell array of the array of the PIDL
@@ -77,7 +78,7 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths)
7778
hr = pDesktopWallpaper.Get()->SetSlideshow(pShellItemArray.Get()).ThrowOnFailure();
7879

7980
// Free the allocated PIDL
80-
for (uint dwIndex = 0u; dwIndex < (uint)aszPaths.Length; dwIndex++)
81+
for (uint dwIndex = 0u; dwIndex < dwCount; dwIndex++)
8182
PInvoke.ILFree(ppItemIdList[dwIndex]);
8283

8384
// Set wallpaper position to fill the monitor.

0 commit comments

Comments
 (0)