Reputation: 33605
I want to programmatically set a wallpaper. Here's the only solution I've found so far:
SystemParametersInfoW(SPI_SETDESKWALLPAPER, 1, (void*)wallpaperImageFilePath.utf16(), SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
My question is: how to tell Windows I want the wallpaper image centered (not resized)? The solution above always sets the image in stretch mode. According to MSDN, there are no flags to accompany SPI_SETDESKWALLPAPER
.
Upvotes: 3
Views: 13628
Reputation: 6738
As of Windows 8 there is now a published interface for setting the desktop background. Specifically the IDesktopBackground::SetWallpaper
method. MSDN Documentation
The interface also has several methods for getting and setting the configuration of the slideshow, and obtaining the required monitor device paths.
Upvotes: 13
Reputation: 598029
There is no API function for setting the wallpaper orientation. You have to go to the Registry directly instead, specifically the "WallpaperStyle"
and "TileWallpaper"
values of the HKEY_CURRENT_USER\Control Panel\Desktop
key. See this article for an example:
Set the desktop wallpaper (CppSetDesktopWallpaper)
Upvotes: 6