使用 Win API 设置壁纸 [英] Setting wallpaper with Win API
问题描述
我想以编程方式设置壁纸.这是我目前找到的唯一解决方案:
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);
我的问题是:如何告诉 Windows 我想要壁纸图像居中(不调整大小)?上面的解决方案总是将图像设置为拉伸模式.根据 MSDN,SPI_SETDESKWALLPAPER
没有附带标志.
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
.
推荐答案
没有设置壁纸方向的 API 函数.您必须直接转到注册表,特别是 HKEY_CURRENT_USER\Control Panel\Desktop
键的 "WallpaperStyle"
和 "TileWallpaper"
值.请参阅这篇文章以获取示例:
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:
设置桌面壁纸(CppSetDesktopWallpaper)
这篇关于使用 Win API 设置壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!