如何检测墙纸改变,因为Windows 7的幻灯片显示的结果?墙纸、幻灯片、结果、Windows

2023-09-03 11:39:08 作者:淡笑看过尘世。

我写了需要知道桌面墙纸改变时的程序。经过一番搜索,我找到了部分解决方案: http://www.neowin.net/forum/topic/ 567779网 - 检测 - 壁纸 - 改变/

I am writing a program that needs to know when the desktop wallpaper changes. After some searching, I found a partial solution: http://www.neowin.net/forum/topic/567779-net-detect-wallpaper-change/

从本质上讲,它说,监听 WM_SETTINGCHANGE 消息,并检查壁纸。不幸的是,不会出现此消息时墙纸改变作为Windows 7壁纸幻灯片显示的结果将被发送。事实上,没有任何消息似乎被发送到我的应用程序在所有的这(我见过的WndProc 的没有的获取不变消息的唯一时间:))

Essentially, it says to listen for the WM_SETTINGCHANGE message, and check the wallpaper. Unfortunately, this message does not appear to be sent when the wallpaper is changed as a result of the Windows 7 wallpaper slideshow. In fact, no message seems to be sent to my application at all for this (the only time I've ever seen WndProc not get constant messages :)).

所以我的问题是,短轮询的更改注册表和墙纸文件,有没有一种方法来检测,当出现这种情况?有谁知道在哪里可以找到API文档,列出哪些函数被调用?

So my question is, short of polling the registry and wallpaper file for changes, is there a way to detect when this happens? Does anyone know where I can find API docs that list what function gets called?

推荐答案

其实我想出了一个解决方法的问题。这事实上是在注册表通报机制,因此有可能引发一个事件时,指定的键/值的变化。 HKEY_CURRENT_USER \控制面板\桌面\壁纸是关键。当幻灯片改变壁纸此没有得到改变,但是在该位置的文件不改变。通过监控文件的变化,你实际上可以被通知这一变化。

Actually I figured out a workaround to the issue. There's actually a registry notification mechanism, so it's possible to raise an event when a specified key/value changes. HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper is the key. This doesn't get changed when the slideshow changes the wallpaper, but the file at that location does change. By monitoring the file for changes you can actually be notified of this change.

顺便说一句,整点的应用程序,我在编写依赖的,所以忽略它不会是一种选择:)。

Incidentally, the whole point of the app I was coding relied on that, so omitting it wouldn't be an option :).

感谢您的回复,但 - 帮助把我的良心休息的问候不必经过做事的这种迂回的方式。

Thanks for your reply though - helped put my conscience to rest in regards to having to go through such a roundabout way of doing things.