使用 Win API 设置壁纸 [英] Setting wallpaper with Win API

查看:53
本文介绍了使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆