Bonjour,
Merci d'avoir contacté la communauté Q&A France.
Pour plus d'informations, je partage la réponse à votre question reçue dans le forum anglais:
Cordialement,
Nina
Ce navigateur n’est plus pris en charge.
Effectuez une mise à niveau vers Microsoft Edge pour bénéficier des dernières fonctionnalités, des mises à jour de sécurité et du support technique.
Context
I have a console application in .Net 6 C# that changes the current user's desktop wallpaper to an image for a given time. I backup the current wallpaper configuration of the user by reading the registry. At the end of the givent time, I would like to restore the wallpaper configuration the user had at the beginning.
I managed to restore the image mode and color mode but I didn't managed to restore Slideshow nor Windows Spotlight mode. Ideally I'd like it to work on Windows 10, 11, Windows Server 2016, 2019 and 2022 (I realize there might be differences between thos environments).
The keys I use to read the curent configuration
HKCU\Control Panel\Desktop\Wallpaper # to read the wallpaper image filepath
HKCU\Control Panel\Desktop\WAllpaperStyle # to read the wallpaper image style (fill, fit ...)
HKCU\Control Panel\Colors\Background # to read the background color
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers\BackgroundType # to read the background mode (image, color, slideshow, windows spotlight)
Solutions for restoring Image and colors
To restore the image I used the IDesktopWallpaper interface and to restore colors, I used registry keys:
HKCU\Control Panel\Colors\Background # to restore the saved color
HKCU\Control Panel\Desktop\Wallpaper = "" # to not show any image
HKCU\Control Panel\Desktop\WallpaperStyle = 0
HKCU\Control Panel\Desktop\TileWallpaper = 0
I then called the following function to refresh the desktop by reading the registry.
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, null, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
Solutions tried for restoring Slideshow
I tried 2 solutions: using the IDesktopWallpaper interface with SetSlideshow() and setting some registry keys.
For the IDesktopWallpaper.SetSlideshow, I don't know how I can transform from a List<File> to a IShellItemArray. (see https://learn.microsoft.com/fr-fr/windows/win32/api/shobjidl_core/nf-shobjidl_core-idesktopwallpaper-setslideshow)
For the registry solution, I tried setting the following registry keys but the wallpaper simply switch from image mode to color mode.
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers\SlideshowEnabled = 1 # Activate slideshow mode
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers\SlideshowDirectoryPath = "My/Specific/Folder/Path" # Specifies the folder to scan for images
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers\SlideshowTickCount = 60000 # Specifies the delay between two images
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers\BackgroundType = 2 # Specifies the slideshow mode
HKCU\Control Panel\Personalization\Desktop Slideshow\Interval = 60000 # For any reasons there is an other key to specify the delay between two images
HKCU\Control Panel\Personalization\Desktop Slideshow\Shuffle = 0 # Whether or not images should be displayed in random order
HKCU\Control Panel\Desktop\Wallpaper = "" # to not show any image
HKCU\Control Panel\Desktop\WallpaperStyle = 6 # apparently this could have a role in specifying slideshow mode
HKCU\Control Panel\Desktop\TileWallpaper = 0
Are there any other API that exists that I didn't mention? Am I missing something in the slideshow configuration?
Bonus Question: Is it possible to restore the Windows spotlight mode for wallpaper?
Bonjour,
Merci d'avoir contacté la communauté Q&A France.
Pour plus d'informations, je partage la réponse à votre question reçue dans le forum anglais:
Cordialement,
Nina