如何检测壁纸何时更改(Windows XP 或更高版本)?
我已经弄清楚如何更改桌面壁纸(互联网上有几十个示例。)
仍然让我困惑的一件事:如何检测壁纸何时更改? (比如通过显示控制面板或其他程序更改它。)
I have figured out how to change the desktop wallpaper (there are dozens of examples on the Internet.)
One thing that still eludes me: how do I detect when the wallpaper has changed? (Say via the Display control panel or another program changing it.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在.NET 中添加 WM_SETTINGCHANGE、SystemEvents.UserPreferenceChanged 的消息处理程序。检查壁纸是否仍然相同。
Add a message handler for WM_SETTINGCHANGE, SystemEvents.UserPreferenceChanged in .NET. Check if the wallpaper is still the same.
下面是 C# 中检索壁纸的示例。您需要添加的只是一些额外的代码来存储最后的壁纸并检查它是否不同。
如果您使用非 .net 语言编写某些内容,则可以使用 Win32 API
RegNotifyChangeKeyValue
函数来检查该值是否已更改:Here is an example in C# to retrieve the wallpaper. All you would need to add is some additional code to store the last wallpaper and check to see if it is different.
If you were writing something in a non .net language you could use the Win32 API
RegNotifyChangeKeyValue
function to check to see if this value has changed: