Beispiel #1
0
        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);
        }
Beispiel #2
0
 public WallpaperModeWindowsMappingAttribute(WindowsWallpaperStyle windowsWallpaperStyle)
 {
     WindowsWallpaperStyle = windowsWallpaperStyle;
 }