Search code examples
.netwpfwinapiwindows-7wallpaper

How can I detect wallpaper changing as a result of the Windows 7 slideshow?


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/

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 :)).

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?


Solution

  • 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.