Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Files.App/Services/Windows/WindowsWallpaperService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public unsafe void SetDesktopWallpaper(string szPath)
{
// Instantiate IDesktopWallpaper
using ComPtr<IDesktopWallpaper> pDesktopWallpaper = default;
HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper).ThrowOnFailure();
HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper);

// Get total count of all available monitors
hr = pDesktopWallpaper.Get()->GetMonitorDevicePathCount(out var dwMonitorCount).ThrowOnFailure();
hr = pDesktopWallpaper.Get()->GetMonitorDevicePathCount(out var dwMonitorCount);

fixed (char* pszPath = szPath)
{
Expand All @@ -31,8 +31,8 @@ public unsafe void SetDesktopWallpaper(string szPath)
for (uint dwIndex = 0u; dwIndex < dwMonitorCount; dwIndex++)
{
// Set the wallpaper
hr = pDesktopWallpaper.Get()->GetMonitorDevicePathAt(dwIndex, &pMonitorId).ThrowOnFailure();
hr = pDesktopWallpaper.Get()->SetWallpaper(pMonitorId, pszPath).ThrowOnFailure();
hr = pDesktopWallpaper.Get()->GetMonitorDevicePathAt(dwIndex, &pMonitorId);
hr = pDesktopWallpaper.Get()->SetWallpaper(pMonitorId, pszPath);

pMonitorId = default;
}
Expand All @@ -44,7 +44,7 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths)
{
// Instantiate IDesktopWallpaper
using ComPtr<IDesktopWallpaper> pDesktopWallpaper = default;
HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper).ThrowOnFailure();
HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper);

uint dwCount = (uint)aszPaths.Length;
ITEMIDLIST** ppItemIdList = stackalloc ITEMIDLIST*[aszPaths.Length];
Expand All @@ -55,15 +55,15 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths)

// Get an IShellItemArray from the array of the PIDL
using ComPtr<IShellItemArray> pShellItemArray = default;
hr = PInvoke.SHCreateShellItemArrayFromIDLists(dwCount, ppItemIdList, pShellItemArray.GetAddressOf()).ThrowOnFailure();
hr = PInvoke.SHCreateShellItemArrayFromIDLists(dwCount, ppItemIdList, pShellItemArray.GetAddressOf());

// Release the allocated PIDL
for (uint dwIndex = 0u; dwIndex < dwCount; dwIndex++)
PInvoke.CoTaskMemFree((void*)ppItemIdList[dwIndex]);

// Set the slideshow and its position
hr = pDesktopWallpaper.Get()->SetSlideshow(pShellItemArray.Get()).ThrowOnFailure();
hr = pDesktopWallpaper.Get()->SetPosition(DESKTOP_WALLPAPER_POSITION.DWPOS_FILL).ThrowOnFailure();
hr = pDesktopWallpaper.Get()->SetSlideshow(pShellItemArray.Get());
hr = pDesktopWallpaper.Get()->SetPosition(DESKTOP_WALLPAPER_POSITION.DWPOS_FILL);
}

/// <inheritdoc/>
Expand Down
Loading