public static void Set(string url, DesktopWallpaperStyle style) { var s = new WebClient().OpenRead(url); var img = System.Drawing.Image.FromStream(s); var tempPath = Path.Combine(Path.GetTempPath(), "wallpaper.bmp"); img.Save(tempPath, System.Drawing.Imaging.ImageFormat.Bmp); var key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true); if (style == DesktopWallpaperStyle.Stretched) { key.SetValue(@"WallpaperStyle", 2.ToString()); key.SetValue(@"TileWallpaper", 0.ToString()); } if (style == DesktopWallpaperStyle.Centered) { key.SetValue(@"WallpaperStyle", 1.ToString()); key.SetValue(@"TileWallpaper", 0.ToString()); } if (style == DesktopWallpaperStyle.Tiled) { key.SetValue(@"WallpaperStyle", 1.ToString()); key.SetValue(@"TileWallpaper", 1.ToString()); } SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, tempPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); }
public void ChangeWallpaper(string url, DesktopWallpaperStyle desktopWallpaperStyle) { LogService.Send((string)Application.Current.Resources["ChangeWallpaper"]); var package = new List <byte> { (byte)FunActionsCommunication.ChangeDesktopWallpaper, (byte)desktopWallpaperStyle }; package.AddRange(Encoding.UTF8.GetBytes(url)); ConnectionInfo.SendCommand(this, package.ToArray()); }