Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int SPIF_UPDATEINIFILE = 0x01;
- const int SPIF_SENDWININICHANGE = 0x02;
- const int SPI_SETDESKWALLPAPER = 0x14;
- public enum TileWallpaper
- {
- None = 0,
- Tile = 1
- }
- public enum WallpaperStyle
- {
- Center = 0,
- Tile = 1,
- Stretch = 2,
- Fit = 6,
- Fill = 10,
- Span = 22
- }
- public static void SetWallpaper(string filePath, WallpaperStyle wallpaperStyle)
- {
- using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Control PanelDesktop", true))
- {
- TileWallpaper tileBit;
- if (wallpaperStyle == WallpaperStyle.Tile)
- {
- tileBit = TileWallpaper.Tile;
- }
- else
- {
- tileBit = TileWallpaper.None;
- }
- registryKey.SetValue(@"TileWallpaper", ((int)tileBit).ToString());
- registryKey.SetValue(@"WallpaperStyle", ((int)wallpaperStyle).ToString());
- int returnCode = Win32.SystemParametersInfo(SPI_SETDESKWALLPAPER,
- 0,
- filePath,
- SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
- }
- }
Add Comment
Please, Sign In to add comment