Skip to content

Commit 9a4fd55

Browse files
committed
Use this
1 parent 63fee65 commit 9a4fd55

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@ public sealed class WindowsWallpaperService : IWindowsWallpaperService
1818
public unsafe void SetDesktopWallpaper(string szPath)
1919
{
2020
using ComPtr<IDesktopWallpaper> pDesktopWallpaper = default;
21-
var desktopWallpaperIid = typeof(IDesktopWallpaper).GUID;
22-
var desktopWallpaperInstanceIid = typeof(DesktopWallpaper).GUID;
23-
24-
PInvoke.CoCreateInstance(
25-
&desktopWallpaperInstanceIid,
26-
null,
27-
CLSCTX.CLSCTX_LOCAL_SERVER,
28-
&desktopWallpaperIid,
29-
(void**)pDesktopWallpaper.GetAddressOf())
30-
.ThrowOnFailure();
21+
pDesktopWallpaper.CoCreateInstance<DesktopWallpaper>().ThrowOnFailure();
3122

3223
pDesktopWallpaper.Get()->GetMonitorDevicePathCount(out var dwMonitorCount);
3324

@@ -48,16 +39,7 @@ public unsafe void SetDesktopWallpaper(string szPath)
4839
public unsafe void SetDesktopSlideshow(string[] aszPaths)
4940
{
5041
using ComPtr<IDesktopWallpaper> pDesktopWallpaper = default;
51-
var desktopWallpaperIid = typeof(IDesktopWallpaper).GUID;
52-
var desktopWallpaperInstanceIid = typeof(DesktopWallpaper).GUID;
53-
54-
PInvoke.CoCreateInstance(
55-
&desktopWallpaperInstanceIid,
56-
null,
57-
CLSCTX.CLSCTX_LOCAL_SERVER,
58-
&desktopWallpaperIid,
59-
(void**)pDesktopWallpaper.GetAddressOf())
60-
.ThrowOnFailure();
42+
pDesktopWallpaper.CoCreateInstance<DesktopWallpaper>().ThrowOnFailure();
6143

6244
var dwCount = (uint)aszPaths.Length;
6345

0 commit comments

Comments
 (0)