public static void SetWallpaper(string filePath, WindowsWallpaperStyle style) { var attr = style.GetAttribute <WindowsWallpaperStyleValuesAttribute>(); if (attr != null) { using var key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true); key?.SetValue("WallpaperStyle", attr.WallpaperStyle); key?.SetValue("TileWallpaper", attr.TileWallpaper); } var success = SystemParametersInfo(SetWallpaperOperation, 0, filePath, UpdateIniFile | SendWinIniChange); if (success) { return; } var error = Marshal.GetLastWin32Error(); throw new Win32Exception(error); }
public WallpaperModeWindowsMappingAttribute(WindowsWallpaperStyle windowsWallpaperStyle) { WindowsWallpaperStyle = windowsWallpaperStyle; }