Guest User

Untitled

a guest
Jun 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. const int SPIF_UPDATEINIFILE = 0x01;
  2. const int SPIF_SENDWININICHANGE = 0x02;
  3. const int SPI_SETDESKWALLPAPER = 0x14;
  4.  
  5. public enum TileWallpaper
  6. {
  7. None = 0,
  8. Tile = 1
  9. }
  10.  
  11. public enum WallpaperStyle
  12. {
  13. Center = 0,
  14. Tile = 1,
  15. Stretch = 2,
  16. Fit = 6,
  17. Fill = 10,
  18. Span = 22
  19. }
  20.  
  21. public static void SetWallpaper(string filePath, WallpaperStyle wallpaperStyle)
  22. {
  23. using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Control PanelDesktop", true))
  24. {
  25. TileWallpaper tileBit;
  26. if (wallpaperStyle == WallpaperStyle.Tile)
  27. {
  28. tileBit = TileWallpaper.Tile;
  29. }
  30. else
  31. {
  32. tileBit = TileWallpaper.None;
  33. }
  34. registryKey.SetValue(@"TileWallpaper", ((int)tileBit).ToString());
  35. registryKey.SetValue(@"WallpaperStyle", ((int)wallpaperStyle).ToString());
  36.  
  37. int returnCode = Win32.SystemParametersInfo(SPI_SETDESKWALLPAPER,
  38. 0,
  39. filePath,
  40. SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
  41. }
  42. }
Add Comment
Please, Sign In to add comment